Operations - Waigo01/math_utils_lib GitHub Wiki
In terms of supported operations, the library supports most common operations on scalars, vectors and matrices and implements some special operations for numerical derivatives, numerical integrals, numerical sums, conditional statements and equation solving.
The following is a list of all operations with a short explanation:
a&b: Check if both a and b are true. Booleans are implemented with 0 = false and any other value being true
a|b: Check if either a or b are true
a=b or f(x) = x^2: This is the basic assignment operator. This way you can assign values to variables or expressions to functions
a==b: Check if a = b is true
a!=b: Check if a = b is false
a<b: Check if a is less than b
a>b: Check if a is greater than b
a<=b: Check if a is less than or equal to b
a>=b: Cehck if a is greater than or equal to b
!a: Return the boolean not of a
a+b: Add two scalars, vectors, or matrices
a-b: Subtract two scalars, vectors, or matrices
a+-b: Add and subtract two scalars, vectors or matrices (This allows for ±√)
-a: Return the negative of a
a*b: Multiply a scalar, vector or matrix with each other (Dotproduct, Matrix multiplication, Scalar multiplication, ...)
a/b: Divide two scalars or a vector or matrix with a scalar
A#B: Calculate the cross product, only works with dim(V) <= 3. When dim(V) < 3 the vector gets augmented with zeros.
3a: Hidden multiplication between scalar and variable or parentheses
a^b: Take a scalar or matrix to the power of a scalar using "^"
a^^n: Calculate the repeated exponential, i.e a^a^a^a.. n times
A@a: Index into vector using "?" (e.g. [3, 5, 7]?1 = 5)
D(f, n, m): Calculate the derivative of a function f in respect to n at a value m
I(f, n, a, b): Calculate the integral of a function f in respect to n with the bounds a and b
S(f, n, a, b): Calculate the sum of a function f in respect to n with the bounds a and b
eq(eq_1, eq_2, eq_3, ..., x, y, z, ...): Solve the given equation(s) in terms of the given variable(s)
if(a, t, e) or if(a, t): Return t if a is true, e otherwise or nothing if e is not given
The following operations are only supported if the number type implements StandardFunctions and returns them in the default_functions method.
sin(x): Calculate the sin of a scalar
cos(x): Calculate the cos of a scalar
tan(x): Calculate the tan of a scalar
sinh(x): Calculate the sinh of a scalar
cosh(x): Calculate the cosh of a scalar
tanh(x): Calculate the tanh of a scalar
exp(x): Calculate e^x
abs(x): Calculate the absolute value of a scalar or a vector (length of the vector)
sqrt(x): Calculate the square root of a scalar
root(x, n): Calculate the nth root of a scalar
ln(x): Calculate the natural log of a scalar
arcsin(x): Calculate the arcsin of a scalar
arccos(x): Calculate the arccos of a scalar
arctan(x): Calculate the arctan of a scalar
det(M): Calculate the determinant of the matrix M
inv(M): Calculate the inverse of the matrix M
fact(x): Calculate the factorial of x. In the case of f64 and Complex this is implemented with the Gamma function
For example:
3+4 = 7
3+-sqrt(9) = {0, 6}
[3, 2, 1]@0 = 3
sin(0) = 0
[3, 1, 6]*[2, 7, 1] = 19
eq(x^2 = 9, x) = {3, -3}