Mathematica

Bracketing

Parenthesis ()
change the priorities in computing.
Square bracket []
function parameters, e.g. f[x].
Curly brace {}
list, e.g. {a, b, c}.
Double bracket
abbreviation of Part, e.g. v[[i]].

Constants

CommandValue
Pi\(\pi\)
E\(e\)
I\(i = \sqrt{-1}\)
Infinity\(\infty\)

Data objects

CommandMeaning
2 + 8 Icomplex
"text"string

Defining variables, functions, and rules

CommandMeaning
x = valueassignment
x := valuedelayed assignment
x = . or Clear[x]remove value assigned to x
f[x_] := expressiondefine a function f(x)
expression /. x->areplace x by a in expression
expression //. x->areplace repeatedly
lhs :> rhs /; testapply rule if test is True

Linear algebra

CommandMeaning
{a, b, c}vector, list
{{a, b}, {c, d}}2 × 2 matrix
n.mmatrix multiply
Inverse[m]inverse of matrix
Transpose[m]transpose
Det[m]determinant
MatrixPower[m, n]m^n
MatrixExp[m]e^m
LinearSolve[m, b]solve mx = b
Eigenvalues[m]eigenvalues
Eigenvectors[m]eigenvectors
Eigensystem[m]eigenvalues and eigenvectors

Algebraic calculation

CommandMeaning
Solve[lhs==rhs, x]solve algebraic equation for x
DSolve[eqn, y[x], x]solve differential equation
Reduce[eqn, x]reduce equations
Eliminate[eqn, x]eliminate variable x

Calculus

CommandMeaning
D[f, x]\(\partial f/\partial x\)
D[f, {x,n}\(\partial^n f/\partial x^n\)
Dt[f]\(df\)
Integrate[f, x]\(\int fdx\)
Integrate[f, {x, a, b}]\(\int_a^b f dx\)
Sum[f, {i, m, n}]\(\sum_{i=m}^n f\)
Product[f, {i, m, n}]\(\prod_{i=m}^n f\)
Limit[f, x->a]\(\lim_{x\to a} f\)

Input and output

CommandMeaning
<<fileread expressions from file, return last expression.
expression>>filewrite expression to file.
expression>>>fileappend expression to file.
!!filedisplay the content of file.
Save["file", x]save the definition of x to file.
!commandissue a UNIX command.

Expression in different formats

CommandMeaning
FullForm[e]full form
InputForm[e]input
OutputForm[e]out
CForm[e]C codes
FortranFormfortran
MatrixForm[e]matrix
StandardForm[e]math
TeXForm[e]TEX

Programming

Table[expression, {i, max}]
make a list of values of expression with i from 1 to max.
Module[{a, b, c}, expression1; expression2;…]
a procedure with local variables a, b, c return value of last expression.
Do[expression, {i, min, max, di}]
evaluate expression with i run from min to max in steps of di.
While[test, body]
evaluate body repeatedly, so long as test is True.
For[star,test,inc,body]
evaluate start, then repeatedly evaluate body and inc, until test fails.
If[test, then, else]
evaluate then if test is True, and else if it is False.
Which[test1,value1,test2,value2,…]
give the value associated with the first test that is True.
Switch[expression, form1, value1, form2, value2, …]
give the value associated with first form matching expression.
Function[x, body]
specify a pure function.
Nest[f, x, n]
apply the function f nested n times to x.
Apply[f, {a, b, c}]
f(a, b, c).
Map[f, {a, b, c}]
apply f to each elements, {f(a), f(b), f(c)}.

NR - Numerology

Since release 15, new radio (NR) system has explicitly proposed the concept of numerology, which is used to represent the scaling of subcarrier bandwidth, FFT size, etc.

[Read More]

Python - Einops

Einstein-inspired notation for operations (Einops1) is a python package which provides extremely flexible and powerful opertions on tensors, e.g., permuting/reordering, reshaping (combining and partitioning along axes), reducing, repeating. Moreover, it supports numpy, tensorflow, pytorch, etc.

[Read More]

Sparse Array

Concepts

Given a sparse array, the locations of its component antennas/sensors can be normalized to a minimum inter-antenna distance, denoted by \(d\), e.g., typically \(d = \lambda / 2\). Accordingly, a sparse array can be simply denoted by an integer set \(\mathbb{S}\), and the locations of the antennas are \(nd\), \(n \in \mathbb{S}\).

Given a sparse array \(\mathbb{S}\), its difference coarray (DCA) is defined as \[\begin{aligned} \mathbb{D} \triangleq \{n_1 - n_2 \mid n_1, n_2 \in \mathbb{S}\}. \end{aligned}\]

  • Each entry in \(\mathbb{D}\) is termed a spatial lag.
  • The cardinality of DCA, i.e., \(|\mathbb{D}|\), is termed degree of freedom (DoF) of the sparse array \(\mathbb{S}\).
  • Clearly, DCA is symmetric, i.e., \(\forall n \in \mathbb{D}\), \(-n \in \mathbb{D}\).

Let \(\mathbb{U}\) denote the central ULA segment of \(\mathbb{D}\). Its cardinality \(|\mathbb{U}|\) is termed uniform degree of freedom (UDoF). Then, the number of uncorrelated sources which can be identified is \(\dfrac{|\mathbb{U}| - 1}{2}\).

[Read More]

Direction Cosine

In 3-dimension (3-D) space, a non-zero vector can be denoted by \[\begin{aligned} \mathbf{v} = v_x \mathbf{e}_x + v_y \mathbf{e}_y + v_z \mathbf{e}_z, \end{aligned}\] where

[Read More]

Estimation of Signal Parameters by Rotational Invariance Techniques (ESPRIT)

Estimation of Signal Parameters by Rotational Invariance Techniques (ESPRIT), as its name indicates, is an algorithm to estimate the frequency of sinusoid waves from a noisy mixture of them. Additionally, it can also be used for direction of arrival (DoA) estimation in a multiantenna system. This post describes its principle.

[Read More]