Skip to main content

Algebraic and Transcendental Functions

Algebraic functions​

FunctionDescription
sq(x)x2x^2
sqrt(x)x\sqrt{x}
cb(x)x3x³
cbrt(x)x3\sqrt[3]{x}

Complex numbers​

The Math module also calculates in the complex number space with the data type <cxFlt>. The following functions compose complex values and decompose them again:

FunctionDescription
cx(re, im)Forms a complex number from the real part re and the imaginary part im
re(x)Real part. A real value returns itself
im(x)Imaginary part. A real value returns 00
conj(x)Complex conjugate x‾\overline{x}, the sign of the imaginary part is inverted

The imaginary unit is available as the constant j.

z = cx(3, 4); // 3 + 4j
zq = z * conj(z); // 25, the imaginary part cancels out
a = re(z); // 3
b = im(z); // 4

Polynomial "poly" (Horner scheme)​

The poly() function can be used to efficiently calculate a polynomial by applying the Horner scheme. In the implementation, the explicit exponentiation of xx is avoided by the clever bracketing of terms.

p(x)=aN⋅xn+...+a1⋅x+a0=((aN⋅x+aN−1)⋅x...+a1)⋅x+a0p(x) = a_N \cdot x^n + ... + a_1 \cdot x + a_0 = ((a_N \cdot x + a_{N-1}) \cdot x ... + a_1) \cdot x + a_0
px1 = poly(x, an, ...a1, a0);
A_Coef = [an, ...a1, a0];
px2 = poly(x, A_Coef);

In the second form, the coefficients aN...a0a_N ... a_0 are passed as a vector.

Transcendent functions​

FunctionDescription
log(x)log10(x)log_{10}(x), logarithm of x to the base 10
lg2(x)log2(x)log_{2}(x), logarithm of x to the base 2
ln(x)ln(x)ln(x), natural logarithm
ln1p(x)ln(1+x)ln(1 + x), (better resolution for x close to 0)
pow(x,y)
x^y
xyx^y, exponentiation of x with y
exp10(x)10x10^x, exponentiation of 10 with x
exp2(x)2x2^x, exponentiation of 2 with x
exp(x)exe^x, exponentiation of the Euler constant e with x
expm1(x)ex−1e^x - 1, (better resolution for x near 0)

Trigonometric and arc functions​

All angle arguments must be passed in radians. Accordingly, angles are also returned in radians

FunctionDescription
sin(x)sine of x
cos(x)cosine of x
tan(x)tangent of x
asin(x)arc sine of x
acos(x)arc cosine of x
atan(x)arc tangent of x
atanYX(y,x)Inverse tangent of anticathete y and anticathete x
Function also ensured for x = 0
Correct result for all quadrants in the range [−π,π][-\pi, \pi]

Angle conversion​

FunctionDescription
rad2deg(x)Conversion of the angle x from radians to degrees
deg2rad(x)Conversion of the angle x from radians to radians

Hyperbolic and area functions​

FunctionDescription
sinh(x)hyperbolic sine of x
cosh(x)Cosine hyperbolic of x
tanh(x)hyperbolic tangent of x
asinh(x)area sine hyperbolic of x
acosh(x)area-cosine hyperbolic of x
atanh(x)area-tangent hyperbolic of x