Intro to Mathematica/WolframLang Notation
Here's a very brief intro to WolframLang syntax, showing just the most commonly used syntax that is not obvious.
Arithmetic Operator
x ^ y
means x raised to power of y.
Brackets
- Square brackets means function argument. e.g.
Sin[x]
- Parenthesis means order of operation. e.g.
(3 + 5) * 2
- Curly braces means list. e.g.
{a,b,c}
, also for vector. Nested list represent a matrx or tree. - Double Square brackets means getting an element from a list. e.g.
{x,y,z}[[1]]
returnsx
.
Vector and Matrix
{a,b}
is a 2D vector.{a,b,c}
is 3D vector.- nested list
{{a,b},{c,d}}
is a matrix, with 1st row{a,b}
, second row{c,d}
. {a,b} . {x,y}
means dot product.{a,b} + {x,y}
means{a + x, b + y}
.c * {x,y}
means{c * x, c * y}
.{x,y} / c
means{x/z, y/z}
.
Function
f[x,y]
is a function.f @ x
is the prefix notation forf[x]
. e.g.Cos @ x
meansCos[x]
,Cos @ Norm @ {x,y}
meansCos[Norm[{x,y}]]
.x // f
is the postfix notation forf[x]
. e.g.x // Cos
meansCos[x]
.#
the hash sign stand for parameter of a function.#
or#1
is first parameter,#2
second, etc.&
(ampersand) means the expression before is a function, with hash sign#
meaning its parameters. e.g.(#1 + #2 &)
is the same asFunction[ {x, y}, x + y ]
Complex Number
I
(Capital letter I) is the imaginary number.Pi
is π.
Misc
- space is implicit multiplication. e.g.
a b
meansa * b
.