Numbers and rounding
sqrt(x)
Section titled “sqrt(x)”The square root of x, with its units halved.
sqrt(16 m^2) = 4 mnthroot(x, n)
Section titled “nthroot(x, n)”The real nth root of x; an odd root of a negative number is negative.
nthroot(-27, 3) = -3abs(x)
Section titled “abs(x)”The absolute value of x, or the magnitude of a complex number. Also written |x|.
abs(-3 kN) = 3 kNThe real part of z.
Re(3 + 4i) = 3The imaginary part of z.
Im(3 + 4i) = 4arg(z)
Section titled “arg(z)”The angle of z in the complex plane, between −π and π.
arg(1i) = 1.571conj(z)
Section titled “conj(z)”The complex conjugate of z, element by element in an array.
conj(3 + 4i) = 3 - 4isign(x)
Section titled “sign(x)”−1, 0 or 1, as x is negative, zero or positive.
sign(-2.5) = -1signum(z)
Section titled “signum(z)”z divided by its magnitude, or 0 when z is 0.
signum(3 + 4i) = 0.6 + 0.8iexp(x)
Section titled “exp(x)”e to the power x.
exp(1) = 2.718The natural logarithm of x.
ln(e^2) = 2log(x[, b])
Section titled “log(x[, b])”The logarithm of x to base 10, or to base b.
log(1000) = 3log(8, 2) = 3floor(x)
Section titled “floor(x)”The largest integer not above x.
floor(-2.5) = -3ceil(x)
Section titled “ceil(x)”The smallest integer not below x.
ceil(2.1) = 3round(x[, n])
Section titled “round(x[, n])”x rounded to n decimal places, or to an integer.
round(3.14159, 2) = 3.14trunc(x)
Section titled “trunc(x)”The integer part of x, towards zero.
trunc(-2.7) = -2Floor(x, y)
Section titled “Floor(x, y)”The largest multiple of y not above x; x and y may have units, the same.
Floor(2.7 m, 0.5 m) = 2.5 mCeil(x, y)
Section titled “Ceil(x, y)”The smallest multiple of y not below x.
Ceil(2.7 m, 0.5 m) = 3 mRound(x, y)
Section titled “Round(x, y)”x rounded to the nearest multiple of y.
Round(17 mm, 5 mm) = 15 mmTrunc(x, y)
Section titled “Trunc(x, y)”The multiple of y nearest x towards zero.
Trunc(-2.7, 0.5) = -2.5mod(x, y)
Section titled “mod(x, y)”The remainder of x divided by y, with the sign of x.
mod(17, 5) = 2max(a, b, …)
Section titled “max(a, b, …)”The largest of the numbers given, arrays included element by element.
max(3 m, 450 mm, [1 m; 5 m]) = 5 mmin(a, b, …)
Section titled “min(a, b, …)”The smallest of the numbers given.
min(3, 1, [4; 2]) = 1The gamma function: Γ(n) is (n − 1)! for a whole number n.
Γ(5) = 24gamma(x)
Section titled “gamma(x)”The gamma function, as Γ(x).
gamma(0.5) = 1.772lnΓ(x)
Section titled “lnΓ(x)”The natural logarithm of the gamma function, for large x.
lnΓ(100) = 359.134erf(x)
Section titled “erf(x)”The error function.
erf(1) = 0.843erfc(x)
Section titled “erfc(x)”The complementary error function, 1 − erf(x).
erfc(1) = 0.157