2.0.3 • Published 3 years ago

@colibri-engine/math v2.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

npm.io

Math library

npm.io npm.io npm.io npm.io

Presentation

The engine is based on incremental computation algorithms. When a calculation is submitted to the engine, all the computed values are memorized. So, if you change some variable and query an evaluation, the engine is able to compute the result very fast because it recomputes only what has changed.

Libraries

The API provides several libraries that each comes with dozens of operators.

Imports

Typescript

import {/* required operators */} from '@colibri-engine/math';

Javascript

const {/* required operators */} = require('@colibri-engine/math');

Operators

pow

pow(xnumber, ynumber) ➜ znumber

The pow operator allows you to create a number expression which evals to x power y

const {number} = new ColibriNumberLibrary();  
const {pow} = new ColibriMathLibrary();

const x = number();  
const y = number();  
const z = pow(x, y);

const value = z.eval();

pi

pi() ➜ xnumber

The pi operator allows you to create a number expression which evals to pi (≈1,141593)

const {pi} = new ColibriMathLibrary();

const x = pi();

x.affect(2);

e

e() ➜ xnumber

The e operator allows you to create a number expression which evals to e (≈2,71828)

const {e} = new ColibriMathLibrary();

const x = e();  

x.affect(2);

sqrt

sqrt(xnumber) ➜ ynumber

The sqrt operator allows you to create a number expression which evals to the square root of the given expression

const {number} = new ColibriNumberLibrary();  
const {sqrt} = new ColibriMathLibrary();

const x = number();  
const y = sqrt(x);

const value = y.eval();

x2

x2(xnumber) ➜ ynumber

The x2 operator allows you to create a number expression which evals to the square of x

const {number} = new ColibriNumberLibrary();  
const {x2} = new ColibriMathLibrary();

const x = number();  
const y = x2(x);

const value = y.eval();

x3

x3(xnumber) ➜ ynumber

The x3 operator allows you to create a number expression which evals to the cube of x

const {number} = new ColibriNumberLibrary();  
const {x3} = new ColibriMathLibrary();

const x = number();  
const y = x3(x);

const value = y.eval();

log2

log2(xnumber) ➜ ynumber

The log2 operator allows you to create a number expression which evals to the logarithm neperien of the given expression

const {number} = new ColibriNumberLibrary();  
const {log2} = new ColibriMathLibrary();

const x = number();  
const y = log2(x);

const value = y.eval();

log10

log10(xnumber) ➜ ynumber

The log10 operator allows you to create a number expression which evals to the logarithm decimal of the given expression

const {number} = new ColibriNumberLibrary();  
const {log10} = new ColibriMathLibrary();

const x = number();  
const y = log10(x);

const value = y.eval();

exp

exp(xnumber) ➜ ynumber

The exp operator allows you to create a number expression which evals to the exponential of the given expression

const {number} = new ColibriNumberLibrary();  
const {exp} = new ColibriMathLibrary();

const x = number();  
const y = exp(x);

const value = y.eval();

cos

cos(xnumber) ➜ ynumber

The cos operator allows you to create a number expression which evals to the cosinus of the given expression

const {number} = new ColibriNumberLibrary();  
const {cos} = new ColibriMathLibrary();

const x = number();  
const y = cos(x);

const value = y.eval();

sin

sin(xnumber) ➜ ynumber

The sin operator allows you to create a number expression which evals to the sinus of x

const {number} = new ColibriNumberLibrary();  
const {sin} = new ColibriMathLibrary();

const x = number();  
const y = sin(x);

const value = y.eval();

tan

tan(xnumber) ➜ ynumber

The tan operator allows you to create a number expression which evals to the tangente of x

const {number} = new ColibriNumberLibrary();  
const {tan} = new ColibriMathLibrary();

const x = number();  
const y = tan(x);

const value = y.eval();

cosH

cosH(xnumber) ➜ ynumber

The cosH operator allows you to create a number expression which evals to the hyperbolic cosinus of the given expression

const {number} = new ColibriNumberLibrary();  
const {cosH} = new ColibriMathLibrary();

const x = number();  
const y = cosH(x);

const value = y.eval();

sinH

sinH(xnumber) ➜ ynumber

The sinH operator allows you to create a number expression which evals to the hyperbolic sinus of x

const {number} = new ColibriNumberLibrary();  
const {sinH} = new ColibriMathLibrary();

const x = number();  
const y = sinH(x);

const value = y.eval();

tanH

tanH(xnumber) ➜ ynumber

The tanH operator allows you to create a number expression which evals to the hyperbolic tangente of x

const {number} = new ColibriNumberLibrary();  
const {tanH} = new ColibriMathLibrary();

const x = number();  
const y = tanH(x);

const value = y.eval();

arcCos

arcCos(xnumber) ➜ ynumber

The arcCos operator allows you to create a number expression which evals to the arc cosinus of the given expression

const {number} = new ColibriNumberLibrary();  
const {arcCos} = new ColibriMathLibrary();

const x = number();  
const y = arcCos(x);

const value = y.eval();

arcSin

arcSin(xnumber) ➜ ynumber

The arcSin operator allows you to create a number expression which evals to the arc sinus of the given expression

const {number} = new ColibriNumberLibrary();  
const {arcSin} = new ColibriMathLibrary();

const x = number();  
const y = arcSin(x);

const value = y.eval();

arcTan

arcTan(xnumber) ➜ ynumber

The arcTan operator allows you to create a number expression which evals to the arc tangente of the given expression

const {number} = new ColibriNumberLibrary();  
const {arcTan} = new ColibriMathLibrary();

const x = number();  
const y = arcTan(x);

const value = y.eval();

arcCosH

arcCosH(xnumber) ➜ ynumber

The arcCosH operator allows you to create a number expression which evals to the hyperbolic arc cosinus of the given expression

const {number} = new ColibriNumberLibrary();  
const {arcCosH} = new ColibriMathLibrary();

const x = number();  
const y = arcCosH(x);

const value = y.eval();

arcSinH

arcSinH(xnumber) ➜ ynumber

The arcSinH operator allows you to create a number expression which evals to the hyperbolic arc sinus of the given expression

const {number} = new ColibriNumberLibrary();  
const {arcSinH} = new ColibriMathLibrary();

const x = number();  
const y = arcSinH(x);

const value = y.eval();

arcTanH

arcTanH(xnumber) ➜ ynumber

The arcTanH operator allows you to create a number expression which evals to the hyperbolic arc tangente of the given expression

const {number} = new ColibriNumberLibrary();  
const {arcTanH} = new ColibriMathLibrary();

const x = number();  
const y = arcTanH(x);

const value = y.eval();

trunc

trunc(xnumber) ➜ ynumber

The trunc operator allows you to create a number expression which evals to the truncature of x

const {number} = new ColibriNumberLibrary();  
const {trunc} = new ColibriMathLibrary();

const x = number();  
const y = trunc(x);

const value = y.eval();

sign

sign(xnumber) ➜ ynumber

The sign operator allows you to create a number expression which evals to 1 if x is positive, -1 if x is negative

const {number} = new ColibriNumberLibrary();  
const {sign} = new ColibriMathLibrary();

const x = number();  
const y = sign(x);

const value = y.eval();

inverse

inverse(xnumber) ➜ ynumber

The inverse operator allows you to create a number expression which evals to the inverse of the given expression

const {number} = new ColibriNumberLibrary();  
const {inverse} = new ColibriMathLibrary();

const x = number();  
const y = inverse(x);

const value = y.eval();

floor

floor(xnumber) ➜ ynumber

The floor operator allows you to create a number expression which evals to the floor of the given expression

const {number} = new ColibriNumberLibrary();  
const {floor} = new ColibriMathLibrary();

const x = number();  
const y = floor(x);

const value = y.eval();

ceil

ceil(xnumber) ➜ ynumber

The ceil operator allows you to create a number expression which evals to the ceil of the given expression

const {number} = new ColibriNumberLibrary();  
const {ceil} = new ColibriMathLibrary();

const x = number();  
const y = ceil(x);

const value = y.eval();

min

min(x0number, x1number, ..., xnnumber) ➜ ynumber

The min operator allows you to create a number expression which evals to the lowest given expressions

const {number} = new ColibriNumberLibrary();  
const {min} = new ColibriMathLibrary();

const x0 = number();  
const x1 = number();  
// ...  
const xn = number();  
const y = min(x0, x1, ..., xn) `|` x0.min(x1, ..., xn);

const value = y.eval();

max

max(x0number, x1number, ..., xnnumber) ➜ ynumber

The max operator allows you to create a number expression which evals to the highest given expressions

const {number} = new ColibriNumberLibrary();  
const {max} = new ColibriMathLibrary();

const x0 = number();  
const x1 = number();  
// ...  
const xn = number();  
const y = max(x0, x1, ..., xn) `|` x0.max(x1, ..., xn);

const value = y.eval();

mean

mean(x0number, x1number, ..., xnnumber) ➜ ynumber

The mean operator allows you to create a number expression which evals to the mean value of the given expressions

const {number} = new ColibriNumberLibrary();  
const {mean} = new ColibriMathLibrary();

const x0 = number();  
const x1 = number();  
// ...  
const xn = number();  
const y = mean(x0, x1, ..., xn) `|` x0.mean(x1, ..., xn);

const value = y.eval();

median

median(x0number, x1number, ..., xnnumber) ➜ ynumber

The median operator allows you to create a number expression which evals to median value of the given expressions

const {number} = new ColibriNumberLibrary();  
const {median} = new ColibriMathLibrary();

const x0 = number();  
const x1 = number();  
// ...  
const xn = number();  
const y = median(x0, x1, ..., xn) `|` x0.median(x1, ..., xn);  

const value = y.eval();

gcd

gcd(xnumber, ynumber) ➜ znumber

The gcd operator allows you to create a number expression which evals to the greatest common divisor of the given expressions

const {number} = new ColibriNumberLibrary();  
const {gcd} = new ColibriMathLibrary();

const x = number();  
const y = number();  
const z = gcd(x, y);

const value = z.eval();

npm.io

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago