33math Module

33.1Overview

The math module provices functions for mathematical calculation. This is a built-in module, so you can use it without being imported.

33.2Module Function

math.abs(num):map
Returns an absolute value.
math.acos(num):map:[deg]

Returns an inverse cosine value.

In default, the result is returned in radian. Specifying an attribute :deg would return that in degree.

math.arg(num):map:[deg]

Returns an argument, an angle from the real-axis in the complex plane, of a complex number.

In default, the angle value is returned in radian. Specifying an attribute :deg would return that in degree.

math.asin(num):map:[deg]

Returns an inverse sine value.

In default, the result is returned in radian. Specifying an attribute :deg would return that in degree.

math.atan(num):map:[deg]
Returns an inverse tangent value.
math.atan2(num1, num2):map:[deg]

Returns an inverse tangent value of a fraction of num1 and num2.

In default, the result is returned in radian. Specifying an attribute :deg would return that in degree.

math.bezier(nums[]+:number)
Returns a list that consists of functions that generate coordinates of bezier curves with specified control points. One or more lists of control points can be specified. This means that if you give it two lists of numbers as arguments, it returns two functions of bezier curve.
math.ceil(num):map
Returns a nearest integer number above or equal to the specified value.
math.conj(num):map
Returns a conjugate of a complex number.
math.cos(num):map:[deg]

Returns a cosine value.

In default, the given argument is treated as a radian number. Specifying an attribute :deg would treat that as a degree number.

math.cosh(num):map
Returns a hyperbolic cosine value.
math.covariance(a, b)
Returns a covariance between the a and b.
math.cross (a, b)
Calculates a cross product between a and b.
math.delta(num):map
Evaluates a delta function with a given argument num that returns 1 when num == 0 and 0 otherwise.
math.diff(expr:expr, var:symbol):map {block?}

Calculates a mathematical differential expression of the given expr by a variable var.

If block is specified, it would be evaluated with a block parameter |rtn:expr|, where rtn is the created instance. In this case, the block's result would become the function's returned value.

Example: math.diff((math.sin(x 2)), x)**

math.dot(a, b)
Calculates a dot product between a and b.
math.exp(num):map
Returns an exponential value.
math.fft(seq[])
math.floor(num):map
Returns a nearest integer number below or equal to the specified value.
math.gcd(a:number, b+:number):map
Returns a greatest common divisor among two or more numbers.
math.hypot(x, y):map
Returns a hyperbolic tangent value.
math.imag(num):map
Returns an imaginary part of a complex number.
math.integral()
math.lcm(a:number, b+:number):map
Returns a least common multiple among two or more numbers.
math.least_square(x:iterator, y:iterator, dim:number => 1, var:symbol => `x)
Takes two iterators x and y that return coordinate of points and returns a function that fits them using least square metho. You can specify the fitting curve's dimension by an argument dim, which default value is one. The variable symbol used in the function is x, which can be changed by specifying an argument var.
math.log(num):map
Returns a natural logarithm value.
math.log10(num):map
Returns a decadic logarithm value.
math.norm(num):map
Returns a norm value of a complex number.
math.optimize(expr:expr):map {block?}

Returns an optimized expression of the given argument expr, which needs to be made up of mathematical elements.

If block is specified, it would be evaluated with a block parameter |rtn:expr|, where rtn is the created instance. In this case, the block's result would become the function's returned value.

math.real(num):map
Returns a real part of a complex number.
math.relu(num):map
Evaluates a rectified linear unit function with a given argument num that returns num when num >= 0 and 0 otherwise.
math.sin(num):map:[deg]

Returns a sine value.

In default, the given argument is treated as a radian number. Specifying an attribute :deg would treat that as a degree number.

math.sinh(num):map
Returns a hyperbolic sine value.
math.sqrt(num):map
Returns a square root value.
math.tan(num):map:[deg]

Returns a tangent value.

In default, the given argument is treated as a radian number. Specifying an attribute :deg would treat that as a degree number.

math.tanh(num):map
Returns a hyperbolic tangent value.
math.unitstep(num):map
Evaluates a unit step function with a given argument num that returns 1 when num >= 0 and 0 otherwise.