Nine-Pin Masters

# npm

## @compute.ts/math

2.1.0 • Public • Published

## 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.

compute.ts

## Libraries

The project provides several libraries that each comes with dozens of operators. Please note the cross-compatibility of the libraries.

## Imports

### Typescript

import {/* required operators */} from '@compute.ts/math';

### Javascript

const {/* required operators */} = require('@compute.ts/math');

## Operators

### sum

sum(x[number] | number[]) ➜ ynumber

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

import {number} from "@compute.ts/number"
import {sum} from "@compute.ts/math"
import {array} from "@compute.ts/array"

const x0 = number();
const x1 = number();
// ...
const xn = number();
const arr = array.ofNumber([x0, x1, ..., xn])

const y = sum([x0, x1, ..., xn]) | sum(arr);
const value = y.eval();

### times

times(x[number] | number[]) ➜ ynumber

The times operator allows you to create a number expression which evals to the multiplication of the arrray values

import {number} from "@compute.ts/number"
import {times} from "@compute.ts/math"
import {array} from "@compute.ts/array"

const x0 = number();
const x1 = number();
// ...
const xn = number();
const arr = array.ofNumber([x0, x1, ..., xn])

const y = times([x0, x1, ..., xn]) | times(arr);
const value = y.eval();

### min

min(x[number] | number[]) ➜ ynumber

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

import {number} from "@compute.ts/number"
import {min} from "@compute.ts/math"
import {array} from "@compute.ts/array"

const x0 = number();
const x1 = number();
// ...
const xn = number();
const arr = array.ofNumber([x0, x1, ..., xn])

const y = min([x0, x1, ..., xn]) | min(arr);
const value = y.eval();

### argMin

argMin(x[number] | number[]) ➜ ynumber

The argMin operator allows you to create a number expression which evals to the index of the lowest given expressions

import {number} from "@compute.ts/number"
import {argMin} from "@compute.ts/math"
import {array} from "@compute.ts/array"

const x0 = number();
const x1 = number();
// ...
const xn = number();
const arr = array.ofNumber([x0, x1, ..., xn])

const y = argMin([x0, x1, ..., xn]) | argMin(arr);
const value = y.eval();

### max

max(x[number] | number[]) ➜ ynumber

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

import {number} from "@compute.ts/number"
import {max} from "@compute.ts/math"
import {array} from "@compute.ts/array"

const x0 = number();
const x1 = number();
// ...
const xn = number();
const arr = array.ofNumber([x0, x1, ..., xn])

const y = max([x0, x1, ..., xn]) | max(arr);
const value = y.eval();

### argMax

argMax(x[number] | number[]) ➜ ynumber

The argMax operator allows you to create a number expression which evals to the index of the highest given expressions

import {number} from "@compute.ts/number"
import {argMax} from "@compute.ts/math"
import {array} from "@compute.ts/array"

const x0 = number();
const x1 = number();
// ...
const xn = number();
const arr = array.ofNumber([x0, x1, ..., xn])

const y = argMax([x0, x1, ..., xn]) | argMax(arr);
const value = y.eval();

### mean

mean(x[number] | number[]) ➜ ynumber

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

import {number} from "@compute.ts/number"
import {mean} from "@compute.ts/math"
import {array} from "@compute.ts/array"

const x0 = number();
const x1 = number();
// ...
const xn = number();
const arr = array.ofNumber([x0, x1, ..., xn])

const y = mean([x0, x1, ..., xn]) | mean(arr);
const value = y.eval();

### median

median(x[number] | number[]) ➜ ynumber

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

import {number} from "@compute.ts/number"
import {median} from "@compute.ts/math"
import {array} from "@compute.ts/array"

const x0 = number();
const x1 = number();
// ...
const xn = number();
const arr = array.ofNumber([x0, x1, ..., xn])

const y = median([x0, x1, ..., xn]) | median(arr);
const value = y.eval();

### pow

pow(xnumber, ynumber) ➜ znumber

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

import {number} from "@compute.ts/number"
import {pow} from "@compute.ts/math"

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)

import {pi} from "@compute.ts/math"

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)

import {e} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {sqrt} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {x2} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {x3} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {log2} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {log10} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {exp} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {cos} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {sin} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {tan} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {cosH} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {sinH} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {tanH} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {arcCos} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {arcSin} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {arcTan} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {arcCosH} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {arcSinH} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {arcTanH} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {trunc} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {sign} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {inverse} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {floor} from "@compute.ts/math"

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

import {number} from "@compute.ts/number"
import {ceil} from "@compute.ts/math"

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

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

import {number} from "@compute.ts/number"
import {gcd} from "@compute.ts/math"

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

const value = z.eval();

I am a software developer with 4 years of project specializing in the development of web solutions. Digital Nomad, I work while traveling. After 3 years into the french industry, I've started to work as a freelance software architect or fullstack developer.

Based on state-of-the-art web technologies, I offer you to architect & develop the best version of your project. My experience in the web app development assure you to build a nice looking, performant and stable product.

Minimalist, I like to travel, to meet people, learn new things and handmade stuff. Scuba & sky diving licenced. I like also hamburgers, Kinder chocolate and crepes. Karate black belt.

https://berthellemy.com/

### Install

npm i @compute.ts/math

2

2.1.0

MIT

59.9 kB

76