Members
#
(readonly) ErrorCode :number
Enum for all error codes.
Properties
| Name |
Type |
Description |
INT_BIGGER_THAN_MAX_ULL |
number
|
Error Code throwed because a big integer is bigget than the maximum unsigned integer value |
DOUBLE_OVERFLOW |
number
|
Error Code throwed because a Integer value is too big to fit on a 64 bits float |
LONG_LONG_OVERFLOW |
number
|
Error Code throwed because a Integer value is too big to fit on a 64 bits integer |
DIVISION_BY_ZERO |
number
|
Error Code throwed because a division by zero occured |
ARG_IS_INVALID |
number
|
Error Code throwed because an argument is invalid |
MATRIX_INVALID_ADDITION |
number
|
Error Code throwed because a reduction encounter a invalid matrix addition |
MATRIX_INVALID_MULTIPLICATION |
number
|
Error Code throwed because a reduction encounter a invalid matrix multiplication |
NUMBER_HAVE_NO_MODULAR_INVERSE |
number
|
Error Code throwed because a number have no modular inverse |
POLY_HAVE_NON_INTEGER_DEGREE |
number
|
Error Code throwed by methods that expects polynomial with integer degrees |
POLY_HAVE_NON_CONSTANT_COEFFICIENT |
number
|
Error Code throwed by methods that expects polynomial expressions with constant coefficients |
ARG_IS_NOT_SYM_EXPR |
number
|
Error Code throwed by methods that do not receive a symbol expr when expected |
ARG_IS_NOT_POW_EXPR |
number
|
Error Code throwed by methods that do not receive a power expr when expected |
ARG_IS_NOT_INT_EXPR |
number
|
Error Code throwed by methods that do not receive a integer expr when expected |
ARG_IS_NOT_FRA_EXPR |
number
|
Error Code throwed by methods that do not receive a fraction expr when expected |
ARG_IS_NOT_ADD_EXPR |
number
|
Error Code throwed by methods that do not receive a add expr when expected |
ARG_IS_NOT_SUB_EXPR |
number
|
Error Code throwed by methods that do not receive a sub expr when expected |
ARG_IS_NOT_ROOT_EXPR |
number
|
Error Code throwed by methods that do not receive a root expr when expected |
ARG_IS_NOT_POLY_EXPR |
number
|
Error Code throwed by methods that do not receive a poly expr when expected |
ARG_IS_NOT_LIST_EXPR |
number
|
Error Code throwed by methods that do not receive a list when expected |
ARG_IS_NOT_UNIVARIATE_POLY |
number
|
Error Code throwed by methods that do not accept multivariate polynomials |
ARG_IS_IMAGINARY |
number
|
Error Code throwed by methods that do not accept imaginary inputs |
#
Kind
Enumeration of all kinds possible for expressions.
Methods
#
abs(scope, a) → {Expr}
Creates a abs call expression inside a scope, the
expression is not evaluated, only the abstract
tree of the expressions is created during the
execution of this method.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The operand. |
Returns:
The call to abs function expression.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = number(scope, 4);
// call abs
let z = abs(scope, x);
let t = toString(z); // abs(4)
scopeDestroy(scope);
#
add(scope, a, b) → {Expr}
Creates an addition expression inside
a scope, the expression is not evaluated, only the
abstract tree of the expressions is created during
the execution of this method.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The first operand. |
b |
Expr
|
The second operand. |
Example
let scope = scopeCreate();
let x = number(scope, 2.5);
let y = symbol(scope, 'y');
// call add
let z = add(scope, x, y);
let t = toString(z); // 5/2 + y
scopeDestroy(scope);
#
arccos(scope, x) → {Expr}
Return a call to the arccos function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The arccos argument. |
Returns:
A call expression to the arccos function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = arccos(scope, x);
console.log(toString(z)); // arccos(x)
scopeDestroy(scope);
#
arccosh(scope, x) → {Expr}
Return a call to the arccosh function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The arccosh argument. |
Returns:
A call expression to the arccosh function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = arccosh(scope, x);
console.log(toString(z)); // arccosh(x)
scopeDestroy(scope);
#
arccot(scope, x) → {Expr}
Return a call to the arccot function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The arccot argument. |
Returns:
A call expression to the arccot function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = arccot(scope, x);
console.log(toString(z)); // arccot(x)
scopeDestroy(scope);
#
arccsc(scope, x) → {Expr}
Return a call to the arccsc function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The arccsc argument. |
Returns:
A call expression to the arccsc function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = arccsc(scope, x);
console.log(toString(z)); // arccsc(x)
scopeDestroy(scope);
#
arcsec(scope, x) → {Expr}
Return a call to the arcsec function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The arcsec argument. |
Returns:
A call expression to the arcsec function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = arcsec(scope, x);
console.log(toString(z)); // arcsec(x)
scopeDestroy(scope);
#
arcsin(scope, x) → {Expr}
Return a call to the arcsin function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The arcsin argument. |
Returns:
A call expression to the arcsin function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = arcsin(scope, x);
console.log(toString(z)); // arcsin(x)
scopeDestroy(scope);
#
arctan(scope, x) → {Expr}
Return a call to the arctan function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The arctan argument. |
Returns:
A call expression to the arctan function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = arctan(scope, x);
console.log(toString(z)); // arctan(x)
scopeDestroy(scope);
#
arctanh(scope, x) → {Expr}
Return a call to the arctanh function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The arctanh argument. |
Returns:
A call expression to the arctanh function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = arctanh(scope, x);
console.log(toString(z)); // arctanh(x)
scopeDestroy(scope);
#
cos(scope, x) → {Expr}
Return a call to the cos function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The cos argument. |
Returns:
A call expression to the cos function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = cos(scope, x);
console.log(toString(z)); // cos(x)
scopeDestroy(scope);
#
cosh(scope, x) → {Expr}
Return a call to the cosh function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The cosh argument. |
Returns:
A call expression to the cosh function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = cosh(scope, x);
console.log(toString(z)); // cosh(x)
scopeDestroy(scope);
#
cot(scope, x) → {Expr}
Return a call to the cot function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The cot argument. |
Returns:
A call expression to the cot function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = cot(scope, x);
console.log(toString(z)); // cot(x)
scopeDestroy(scope);
#
coth(scope, x) → {Expr}
Return a call to the coth function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The coth argument. |
Returns:
A call expression to the coth function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = coth(scope, x);
console.log(toString(z)); // coth(x)
scopeDestroy(scope);
#
csc(scope, x) → {Expr}
Return a call to the csc function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The csc argument. |
Returns:
A call expression to the csc function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = csc(scope, x);
console.log(toString(z)); // csc(x)
scopeDestroy(scope);
#
csch(scope, x) → {Expr}
Return a call to the csch function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The csch argument. |
Returns:
A call expression to the csch function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = csch(scope, x);
console.log(toString(z)); // csch(x)
scopeDestroy(scope);
#
denominator(scope, a) → {Expr}
Return a new expression equal to the denominator of
an expression.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The expression. |
Returns:
The denominator expresion.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = number(scope, 1);
let y = number(scope, 2);
let z = div(scope, x, y);
let w = denominator(scope, z);
console.log(toString(w)); // 1
scopeDestroy(scope);
#
derivative(scope, u, x) → {Expr}
Compute the derivative of an expression by a given
symbol.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
u |
Expr
|
A polynomial expression. |
x |
Expr
|
A symbol expression. |
Returns:
The derivative of u by x.
-
Type
-
Expr
#
errorArg(The) → {number}
Get the error argument, this argument is an
number where its meaning is dependent on the
context and errro code throwed.
Parameters:
| Name |
Type |
Description |
The |
GaussError
|
error object. |
Get the error code of an error object.
Parameters:
| Name |
Type |
Description |
The |
GaussError
|
error object. |
Returns:
The error code of the
error object.
-
Type
-
ErrorCode
#
evalSymbol(scope, a, x, v) → {Expr}
Return a new expression where the symbol 'x' on 'a'
is replaced by 'v' and the resulting expression is
reduced.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The expression object. |
x |
Expr
|
The symbol to be replaced. |
v |
Expr
|
The expression that will replace x. |
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let y = symbol(scope, 'y');
let z = add(scope, x, y);
console.log(toString(z)); // x + y
let k = evalSymbol(scope, z, x, y);
console.log(toString(k)); // 2*y
scopeDestroy(scope);
#
exp(scope, a) → {Expr}
Return a call to the exp function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The argument for the exp expression. |
Returns:
A call expression to the exp function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = exp(scope, x);
console.log(toString(z)); // exp(x)
scopeDestroy(scope);
#
expand(scope, a) → {Expr}
Return a expanded and reduced expression.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The expression. |
Example
let scope = scopeCreate();
let z = mul(scope,
add(scope,
number(scope, 2),
symbol(scope, 'x'),
),
add(scope,
symbol(scope, 'x'),
number(scope 3)
)
);
console.log(toString(z)); // (2 + x) * (x + 3)
let w = expand(scope, z);
console.log(toString(w)); // x^2 + 5x + 6
scopeDestroy(scope);
#
freeSymbols(scope, u) → {Expr}
Return a set with the free symbols of an expression.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
u |
Expr
|
The expression object. |
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let y = symbol(scope, 'y');
let z = number(scope, 2);
let w = add(scope, x, add(y, z));
let k = freeSymbols(scope, 2);
console.log(toString(k)); // {x, y}
scopeDestroy(scope);
#
getOperand(scope, a, i) → {Expr}
Get the i'th operand of an expression.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The expression object. |
i |
number
|
The index of the operand. |
Returns:
The i'th operand expression.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = number(scope, 1);
let y = number(scope, 2);
let z = number(scope, 3);
let a = add(scope, x, y);
let b = add(scope, a, z);
toString(b); // (1 + 2) + 3
toString(getOperand(scope, b, 0)); // 1 + 2
toString(getOperand(scope, b, 1)); // 3
scopeDestroy(scope);
#
is(a, k) → {Bool}
Return if an expression is of a given set of kinds.
Parameters:
| Name |
Type |
Description |
a |
Expr
|
The expression. |
k |
Kind
|
The kind value. |
Returns:
true if the expression is of at least one
of the given kinds, false otherwise.
-
Type
-
Bool
Example
let scope = scopeCreate();
let x = number(scope, 1);
d *
console.log(is(x, Kind.INT)); // true
console.log(is(x, Kind.DIV)); // false
console.log(is(x, Kind.INT | Kind.DIV)); // true
scopeDestroy(scope);
#
isEqual(a, b) → {Bool}
Computes if two expressions are equal.
Parameters:
| Name |
Type |
Description |
a |
Expr
|
The first operand. |
b |
Expr
|
The second operand. |
Returns:
The result of the comparison.
-
Type
-
Bool
Example
let scope = scopeCreate();
let x = number(scope, 1);
let y = number(scope, 1);
let z = number(scope, 3);
console.log(isEqual(x, y)); // true
console.log(isEqual(x, z)); // false
scopeDestroy(scope);
#
kindOf(a) → {Kind}
Return the kind of the expression.
Parameters:
| Name |
Type |
Description |
a |
Expr
|
The expression. |
Returns:
The Kind of the expresion.
-
Type
-
Kind
Example
let scope = scopeCreate();
let x = number(scope, 1);
let y = symbol(scope,'x');
let z = div(scope, x, y);
console.log(kindOf(x) == Kind.INT); // true
console.log(kindOf(y) == Kind.SYM); // true
console.log(kindOf(z) == Kind.DIV); // true
scopeDestroy(scope);
#
ln(scope, a) → {Expr}
Return a call to the ln function.
G * @example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = ln(scope, x);
console.log(toString(z)); // ln(x)
scopeDestroy(scope);
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The power for the ln expression. |
Returns:
A call expression to the ln function.
-
Type
-
Expr
#
log(scope, a, b) → {Expr}
Return a call to the log function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The power for the log expression. |
b |
Expr
|
The base for the log expression. |
Returns:
A call expression to the log function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let y = symbol(scope, 'y');
let z = log(scope, x, y);
console.log(toString(z)); // log(x, y)
scopeDestroy(scope);
#
matrixDeterminant(scope, M) → {Expr}
Compute the determinant of a matrix expression.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
M |
Expr
|
The matrix expression. |
Returns:
The determinant of the matrix
expression.
-
Type
-
Expr
#
matrixGet(scope, M, row, column) → {Expr}
Return a copy of an element inside a matrix.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
M |
Expr
|
The matrix expression. |
row |
number
|
The rows of element inside the matrix. |
column |
number
|
The column of the element inside the matrix. |
Example
let scope = scopeCreate();
let z = matrixIdentity(scope, 2, 2);
console.log(toString(matrixGet(scope, z, 0, 0))); // 1
console.log(toString(matrixGet(scope, z, 0, 1))); // 0
scopeDestroy(scope);
#
matrixIndentity(scope, rows, columns) → {Expr}
Return a identity matrix.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
rows |
number
|
The number of rows of the matrix. |
columns |
number
|
The number of columns of the matrix. |
Example
let scope = scopeCreate();
let z = matrixIdentity(scope, 2, 2);
console.log(toString(z)); // [[1,0],[0,1]]
scopeDestroy(scope);
#
matrixInverse(scope, M) → {Expr}
Compute the inverse of a matrix expression.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
M |
Expr
|
The matrix expression. |
Returns:
A matrix expression corresponding
to the inverse of M.
-
Type
-
Expr
#
matrixSet(M, row, column, a)
Set an element inside a matrix.
Parameters:
| Name |
Type |
Description |
M |
Expr
|
The matrix expression. |
row |
number
|
The rows of element inside the matrix. |
column |
number
|
The column of the element inside the matrix. |
a |
number
|
The number to be placed on the matrix. |
Example
let scope = scopeCreate();
let z = matrixIdentity(scope, 2, 2);
console.log(toString(z)); // [[1,0],[0,1]]
matrixSet(z, 0, 0, 2);
console.log(toString(z)); // [[2,0],[0,1]]
scopeDestroy(scope);
#
matrixSVD(scope, M) → {Expr}
Compute the singular value decomposition of a matrix
expression.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
M |
Expr
|
The matrix expression. |
Returns:
A list expression with three matrices
representing the singular value decomposition of M.
-
Type
-
Expr
#
matrixTranspose(scope, M) → {Expr}
Compute the transpose of a matrix expression.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
M |
Expr
|
The matrix expression. |
Returns:
The determinant of the matrix
expression.
-
Type
-
Expr
#
matrixZeros(scope, rows, columns) → {Expr}
Return a matrix filled with zeros.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
rows |
number
|
The number of rows of the matrix. |
columns |
number
|
The number of columns of the matrix. |
Example
let scope = scopeCreate();
let z = matrixZeros(scope, 2, 2);
console.log(toString(z)); // [[0,0],[0,0]]
scopeDestroy(scope);
#
mul(scope, a, b) → {Expr}
Creates a multiplication expression inside
a scope, the expression is not evaluated, only the
abstract tree of the expressions is created during
the execution of this method.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The first operand. |
b |
Expr
|
The second operand. |
Returns:
The multiplication expression.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = number(scope, 2.5);
let y = symbol(scope, 'y');
// call mul
let z = mul(scope, x, y);
let t = toString(z); // 5/2 * y
scopeDestroy(scope);
#
number(scope, v) → {Expr}
Creates an expression of numeric type.
This expression is stored internally as a fraction or a big
integer to avoid precision problems with floating point values.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
scope The scope object. |
v |
number
|
A number value. |
#
numerator(scope, a) → {Expr}
Return a new expression equal to the numerator of
an expression.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The expression. |
Example
let scope = scopeCreate();
let x = number(scope, 1);
let y = number(scope, 2);
let z = div(scope, x, y);
let w = numerator(scope, z);
console.log(toString(w)); // 1
scopeDestroy(scope);
#
polynomiaDivisionFiniteField(scope, u, v, p) → {Expr}
Compute the Division of two polynomial expressions
on a finite field of length p.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
u |
Expr
|
A polynomial expression. |
v |
Expr
|
A polynomial expression. |
p |
number
|
A integer number. |
Returns:
The division of u by v on Z_{p}, the
the expression is returned as an addition of quotient
and remainder.
-
Type
-
Expr
#
polynomialCoefficient(scope, p, x, x) → {Expr}
Get the coefficient of a polynomial on a given
symbol and degree.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
p |
Expr
|
The polynomial expression. |
x |
Expr
|
The symbol in p. |
x |
Expr
|
The symbol in p. |
Returns:
The coefficient expression.
-
Type
-
Expr
#
polynomialDegree(scope, p, x) → {Expr}
Get the degree of a polynomial on a given symbol.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
p |
Expr
|
The polynomial expression. |
x |
Expr
|
The symbol in p. |
#
polynomialDivision(scope, u, v) → {Expr}
Compute division between two polynomials and return
a expression of form 'quotient + remainder'
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
u |
Expr
|
A polynomial expression. |
v |
Expr
|
A polynomial expression. |
Returns:
A addition expression where the first
operand is the quotient and the second is the
remainder of the division.
-
Type
-
Expr
#
polynomialFactors(scope, p) → {Expr}
Compute irreducible factorization of a
multivariate polynomial.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
p |
Expr
|
The polynomial expression. |
Returns:
The factorized form of a polynomial expression.
-
Type
-
Expr
#
polynomialGCD(scope, u, v) → {Expr}
Compute greatest commom divisor between two polynomials.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
u |
Expr
|
A polynomial expression. |
v |
Expr
|
A polynomial expression. |
#
polynomialLCM(scope, u, v) → {Expr}
Compute least commom multiple between two polynomials.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
u |
Expr
|
A polynomial expression. |
v |
Expr
|
A polynomial expression. |
#
polynomialLeadingCoefficient(scope, p, x) → {Expr}
Get the leading coefficient of a polynomial on a
given symbol.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
p |
Expr
|
The polynomial expression. |
x |
Expr
|
The symbol in p. |
Returns:
The leading coeffient expression.
-
Type
-
Expr
#
polynomialProjectFiniteField(scope, u, p) → {Expr}
Compute the projection of a polynomial expression
on a finite field of length p.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
u |
Expr
|
A polynomial expression. |
p |
number
|
A integer number. |
Returns:
The projection of u on Z_{p}.
-
Type
-
Expr
#
polynomialResultant(scope, u, v) → {Expr}
Compute the resultant between two polynomial
expressions.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
u |
Expr
|
A polynomial expression. |
v |
Expr
|
A polynomial expression. |
Returns:
The resultant between u and v.
-
Type
-
Expr
#
polynomialRoots(scope, p) → {Expr}
Compute all the real and imaginary roots of an
univariate polynomial with real coefficients.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
p |
Expr
|
The polynomial expression. |
Returns:
A list with all the roots withing
a reasonable precision.
-
Type
-
Expr
#
powBase(scope, a) → {Expr}
Return a new expression equal to the degree of
a pow expression.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The pow expression. |
Example
let scope = scopeCreate();
let x = number(scope, 1);
let y = number(scope, 2);
let z = pow(scope, x, y);
let w = powBase(scope, z);
console.log(toString(w)); // 1
scopeDestroy(scope);
#
powDegree(scope, a) → {Expr}
Return a new expression equal to the degree of
a pow expression.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The pow expression. |
Example
let scope = scopeCreate();
let x = number(scope, 1);
let y = number(scope, 2);
let z = pow(scope, x, y);
let w = powDegree(scope, z);
console.log(toString(w)); // 2
scopeDestroy(scope);
#
prime(scope, i) → {Expr}
Compute the i'th prime number.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
i |
number
|
The index of the prime number. |
#
primeFactors(scope, a) → {Expr}
Compute the prime factorization of a integer
expression.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The integer expression. |
Returns:
The product of all prime factors of a.
The first number returned is 1 or -1, meaning the sign of a.
-
Type
-
Expr
#
reduce(scope, a) → {Expr}
Return a reduced expression without expanding.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The expression. |
Example
let scope = scopeCreate();
let z = add(scope,
add(scope,
number(scope, 1),
symbol(scope, 'x'),
),
add(scope,
symbol(scope, 'x'),
number(scope 3)
)
);
console.log(toString(z)); // (1 + x) + (x + 3)
let w = reduce(scope, z);
console.log(toString(w)); // 2*x + 4
scopeDestroy(scope);
#
replace(scope, a, x, v) → {Expr}
Return a new expression where the symbol 'x' on 'a'
is replaced by 'v'.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The expression object. |
x |
Expr
|
The symbol to be replaced. |
v |
Expr
|
The expression that will replace x. |
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let y = symbol(scope, 'y');
let z = add(scope, x, y);
console.log(toString(z)); // x + y
let k = replace(scope, z, x, y);
console.log(toString(k)); // y + y
scopeDestroy(scope);
#
root(scope, a, b) → {Expr}
Creates a root call expression inside a scope, the
expression is not evaluated, only the abstract
tree of the expressions is created during the
execution of this method.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The radicand. |
b |
Expr
|
The index. |
Example
let scope = scopeCreate();
let x = number(scope, 4);
let y = number(scope, 2);
// call root
let z = root(scope, x, y);
let t = toString(z); // root(4, 2)
scopeDestroy(scope);
#
rootIndex(scope, a) → {Expr}
Return a new expression equal to the index of
a root expression.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The root expression. |
Example
let scope = scopeCreate();
let x = number(scope, 1);
let y = number(scope, 2);
let z = root(scope, x, y);
let w = rootIndex(scope, z);
console.log(toString(w)); // 2
scopeDestroy(scope);
#
rootRadicand(scope, a) → {Expr}
Return a new expression equal to the radicand of
a root expression.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The root expression. |
Example
let scope = scopeCreate();
let x = number(scope, 1);
let y = number(scope, 2);
let z = root(scope, x, y);
let w = rootRadicand(scope, z);
console.log(toString(w)); // 1
scopeDestroy(scope);
#
scopeAssign(scope, key, a)
Assign one expression to a string key
inside a scope, so the expression can be retrieved
by querying it using the key.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
key |
Expr
|
The string key. |
a |
Expr
|
A expression object. |
#
scopeCreate() → {Scope}
Creates a scope, scopes are needed for
creating and assigning expresions.
Returns:
A scope object that can be used to create
and assign expressions.
-
Type
-
Scope
#
scopeDestroy(scope)
Destroy a scope and deallocate all resources
reserved by it and the expressions that it holds. This
function is neccessary to avoid leaks when using this
library.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object to be destroyed. |
#
scopeGet(scope, key) → {Expr}
Return the expression from the scope
using the string key.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
key |
Expr
|
The key string. |
Returns:
The expresion object assigned to the key.
-
Type
-
Expr
#
sec(scope, x) → {Expr}
Return a call to the sec function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The sec argument. |
Returns:
A call expression to the sec function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = sec(scope, x);
console.log(toString(z)); // sec(x)
scopeDestroy(scope);
#
sech(scope, x) → {Expr}
Return a call to the sech function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The sech argument. |
Returns:
A call expression to the sech function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = sech(scope, x);
console.log(toString(z)); // sech(x)
scopeDestroy(scope);
#
setOperand(a, i, b)
Set the i'th operand of an expression.
Parameters:
| Name |
Type |
Description |
a |
Expr
|
The expression object. |
i |
number
|
The index of the operand. |
b |
Expr
|
The new operand. |
Example
let scope = scopeCreate();
let x = number(scope, 1);
let y = number(scope, 2);
let z = number(scope, 3);
let a = add(scope, x, y);
let b = add(scope, a, z);
console.log(toString(b)); // (1 + 2) + 3
setOperand(b, 0, x);
console.log(toString(b)); // 1 + 3
scopeDestroy(scope);
#
sin(scope, x) → {Expr}
Return a call to the sin function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The sin argument. |
Returns:
A call expression to the sin function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = sin(scope, x);
console.log(toString(z)); // sin(x)
scopeDestroy(scope);
#
sinh(scope, x) → {Expr}
Return a call to the sinh function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The sinh argument. |
Returns:
A call expression to the sinh function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = sinh(scope, x);
console.log(toString(z)); // sinh(x)
scopeDestroy(scope);
#
solveLinearSystem(scope, M, b) → {Expr}
Compute the solution of a linear system.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
M |
Expr
|
The matrix with the equation coefficients. |
b |
Expr
|
The matrix with the equation values. |
Returns:
The matrix expression with the solutions.
-
Type
-
Expr
#
sqrt(scope, a) → {Expr}
Creates a square root call expression inside a scope,
the expression is not evaluated, only the abstract
tree of the expressions is created during the
execution of this method.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The radicand. |
Example
let scope = scopeCreate();
let x = number(scope, 4);
// call sqrt
let z = sqrt(scope, x);
let t = toString(z); // root(4, 2)
scopeDestroy(scope);
#
sub(scope, a, b) → {Expr}
Creates a subtraction expression inside
a scope, the expression is not evaluated, only the
abstract tree of the expressions is created during
the execution of this method.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
a |
Expr
|
The first operand. |
b |
Expr
|
The second operand. |
Returns:
The subtraction expression.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = number(scope, 2.5);
let y = symbol(scope, 'y');
// call sub
let z = sub(scope, x, y);
let t = toString(z); // 5/2 - y
scopeDestroy(scope);
#
symbol(scope, x) → {Expr}
Creates an expression of symbol type.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
A string value. |
#
tan(scope, x) → {Expr}
Return a call to the tan function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The tan argument. |
Returns:
A call expression to the tan function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = tan(scope, x);
console.log(toString(z)); // tan(x)
scopeDestroy(scope);
#
tanh(scope, x) → {Expr}
Return a call to the tanh function.
Parameters:
| Name |
Type |
Description |
scope |
Scope
|
The scope object. |
x |
Expr
|
The tanh argument. |
Returns:
A call expression to the tanh function.
-
Type
-
Expr
Example
let scope = scopeCreate();
let x = symbol(scope, 'x');
let z = tanh(scope, x);
console.log(toString(z)); // tanh(x)
scopeDestroy(scope);
#
toLatex(a) → {String}
Compute a latex representation of
a expression.
Parameters:
| Name |
Type |
Description |
a |
Expr
|
The expression. |
Returns:
The latex representation
of the expression.
-
Type
-
String
#
toString(a) → {String}
Compute a string representation of
a expression.
Parameters:
| Name |
Type |
Description |
a |
Expr
|
The expression. |
Returns:
The string representation
of the expression.
-
Type
-
String