Symbolic algebra, CAS operations, polynomial manipulation, equation solving, simplification
apart
Perform partial fraction decomposition on a rational expression. Decomposes p(x)/q(x) into a sum of simpler fractions when the denominator factors into distinct linear terms.
Syntax
apart(expr | variable) | apart(expr
Type Signatures
Node, string, string, string
Parameters
Name
Type
Description
expr
Node|string
The rational expression to decompose
variable
string
The variable name
Returns
string — Partial fraction decomposition as a string
Declare an assumption about a symbolic variable. Valid properties: positive, negative, integer, real, complex, nonnegative, nonzero. Assumptions are stored globally and can be used by reduce().
Find the asymptotic (leading) behavior of an expression as a variable approaches a point. For rational functions, returns the leading term ratio. For polynomials, returns the leading monomial. For other expressions, falls back to computing the limit.
Syntax
asymptotic(expr | variable | point)
Type Signatures
string | Node, string, number
Parameters
Name
Type
Description
expr
string | Node
The expression
variable
string
The variable name
point
number
The point to approach (use Infinity for infinity)
Returns
string | number — The leading behavior as a string or number
Examples
asymptotic("3*x^4 + 2*x^2 + 1 x Infinity) asymptotic("x + 1 x
Expand an expression treating the listed variables as complex numbers. Substitutes each variable x with x_re + i*x_im, expands, and separates into real and imaginary parts.
Syntax
complexExpand(expr | variables)
Type Signatures
string, Array, Node, Array
Parameters
Name
Type
Description
expr
Node|string
The expression to expand
variables
string[]
List of variable names to treat as complex
Returns
Object — Object with 're' and 'im' string properties
Approximate minimum degree ordering. The minimum degree algorithm is a widely used heuristic for finding a permutation P so that P*A*P' has fewer nonzeros in its factorization than A. It is a gready method that selects the sparsest pivot row and column during the course of a right looking sparse Cho
Parameters
Name
Type
Description
order
Number
0: Natural, 1: Cholesky, 2: LU, 3: QR
m
Matrix
Sparse Matrix
csChol
Computes the Cholesky factorization of matrix A. It computes L and P so L * L' = P * A * P'
Parameters
Name
Type
Description
m
Matrix
The A Matrix to factorize, only upper triangular part used
s
Object
The symbolic analysis from cs_schol()
Returns
Number — The numeric Cholesky factorization of A or null
csCounts
Computes the column counts using the upper triangular part of A. It transposes A internally, none of the input parameters are modified.
Parameters
Name
Type
Description
a
Matrix
The sparse matrix A
ata
Matrix
Count the columns of A'A instead
csLu
Computes the numeric LU factorization of the sparse matrix A. Implements a Left-looking LU factorization algorithm that computes L and U one column at a tume. At the kth step, it access columns 1 to k-1 of L and column k of A. Given the fill-reducing column ordering q (see parameter s) computes L, U
Parameters
Name
Type
Description
m
Matrix
The A Matrix to factorize
s
Object
The symbolic analysis from csSqr(). Provides the fill-reducing
tol
Number
Partial pivoting threshold (1 for partial pivoting)
Returns
Number — The numeric LU factorization of A or null
csSpsolve
The function csSpsolve() computes the solution to G * x = bk, where bk is the kth column of B. When lo is true, the function assumes G = L is lower triangular with the diagonal entry as the first entry in each column. When lo is true, the function assumes G = U is upper triangular with the diagonal
Parameters
Name
Type
Description
g
Matrix
The G matrix
b
Matrix
The B matrix
k
Number
The kth column in B
xi
Array
The nonzero pattern xi[top] .. xi[n - 1], an array of size = 2 * n
x
Array
The soluton to the linear system G * x = b
pinv
Array
The inverse row permutation vector, must be null for L * x = b
lo
boolean
The lower (true) upper triangular (false) flag
Returns
Number — The index for the nonzero pattern
csSqr
Symbolic ordering and analysis for QR and LU decompositions. symbolic ordering and analysis for LU decomposition (false)
Parameters
Name
Type
Description
order
Number
The ordering strategy (see csAmd for more details)
a
Matrix
The A matrix
qr
boolean
Symbolic ordering and analysis for QR decomposition (true) or
Returns
Object — The Symbolic ordering and analysis for matrix A
csSymperm
Computes the symmetric permutation of matrix A accessing only the upper triangular part of A. C = P * A * P'
Parameters
Name
Type
Description
a
Matrix
The A matrix
pinv
Array
The inverse of permutation vector
values
boolean
Process matrix values (true)
Returns
Matrix — The C matrix, C = P * A * P'
curl
Compute the symbolic curl of a 3D vector field. The curl is defined as [dF3/dy - dF2/dz, dF1/dz - dF3/dx, dF2/dx - dF1/dy]. Both field and variables must have exactly 3 elements.
Syntax
curl(field | variables)
Type Signatures
Array, Array
Parameters
Name
Type
Description
field
Array.<string | Node>
Array of 3 component expressions [F1, F2, F3]
variables
Array.<string>
Array of 3 variable names [x, y, z]
Returns
Array.<string> — The curl as an array of 3 strings
Find the degree of a polynomial expression in a specified variable. Walks the expression tree to find the highest power of the given variable. Returns 0 for constant expressions and -Infinity for non-polynomial expressions.
Syntax
degree(polynomial | variable)
Type Signatures
string | Node, string
Parameters
Name
Type
Description
polynomial
string | Node
The polynomial expression
variable
string
The variable name
Returns
number — The degree (highest power) of the variable
Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.
Compute finite differences of a numeric sequence. First differences give the discrete analog of the derivative: Δa[i] = a[i+1] - a[i]. Higher-order differences are computed by applying the operator repeatedly.
Compute the directional derivative of a scalar expression in the given direction. D_v f = gradient(f) · (v / |v|). The direction vector is normalized before computing the dot product with the gradient.
Compute the discriminant of a polynomial. For quadratic ax^2+bx+c: disc = b^2-4ac. For cubic: disc = 18abcd-4b^3d+b^2c^2-4ac^3-27a^2d^2. For higher degrees, uses the resultant of p and its derivative.
Compute the symbolic divergence of a vector field. The divergence is the sum of partial derivatives: div F = dF1/dx1 + dF2/dx2 + ... The field and variables arrays must have the same length.
Assert that a variable belongs to a mathematical domain and record the assumption. Valid domains: Integer, Real, Rational, Complex, Positive, Negative. Returns true when the assumption is stored.
Eliminate specified variables from a system of polynomial equations using resultants. For each variable to eliminate, computes resultants between pairs of equations to produce equations in the remaining variables.
Factor a polynomial expression into its irreducible factors. Uses the rational roots theorem to find rational roots, then performs synthetic division. Handles linear, quadratic, cubic, and higher-degree polynomials with rational roots.
Aggressively simplify an expression by applying multiple strategies (basic simplify, trig identities, expand, rationalize) and returning the result with the fewest nodes.
Syntax
fullSimplify(expr) | fullSimplify(expr | options)
Type Signatures
string, Object, Node, Object
Parameters
Name
Type
Description
expr
Node|string
The expression to simplify
options
Object
Options passed through to simplify
Returns
Node|string — The simplified expression (same type as input)
Expand special function identities: gamma recurrence gamma(n+1)->n*gamma(n), beta(a,b)->gamma(a)*gamma(b)/gamma(a+b), binomial coefficients, and evaluates gamma/factorial at integer arguments.
Syntax
functionExpand(expr)
Parameters
Name
Type
Description
expr
Node|string
The expression to expand
Returns
Node|string — The expanded expression (same type as input)
Compute the symbolic gradient of a scalar expression with respect to a list of variables. Returns an array of strings, where each element is the partial derivative with respect to the corresponding variable.
Syntax
gradientSymbolic(expr | variables)
Type Signatures
string | Node, Array
Parameters
Name
Type
Description
expr
string | Node
The scalar expression
variables
Array.<string>
The variable names
Returns
Array.<string> — Array of partial derivative strings
Compute a Gröbner basis for a polynomial ideal. Supports 1-variable systems (via GCD) and 2-variable systems (via resultant-based reduction) with lexicographic ordering.
Compute the symbolic indefinite integral of an expression with respect to a variable. Handles polynomials (power rule), basic trigonometric functions (sin, cos), exponentials (exp), and 1/x. Uses linearity of integration for sums and constant multiples. Returns the integral without the constant of i
Convenience alias for inverseLaplaceTransform. Compute the inverse Laplace transform using a lookup table of known transform pairs. Supported: 1/s → 1, 1/s^2 → t, c/s^n → c*t^(n-1)/(n-1)!, 1/(s-a) → e^(at), s/(s^2+b^2) → cos(bt), b/(s^2+b^2) → sin(bt), and more.
Compute the symbolic Jacobian matrix of a vector of expressions with respect to a list of variables. J[i][j] = d(exprs[i]) / d(variables[j]). Returns a 2D array of strings.
Syntax
jacobian(exprs | variables)
Type Signatures
Array, Array
Parameters
Name
Type
Description
exprs
Array.<string | Node>
Array of expressions
variables
Array.<string>
Array of variable names
Returns
Array.<Array.<string>> — 2D array of partial derivatives
Compute the Laplace transform of an expression using a table-based approach. Supports: constants (1 -> 1/s), powers (t^n -> n!/s^(n+1)), exponentials (e^(at) -> 1/(s-a)), sine (sin(bt) -> b/(s^2+b^2)), cosine (cos(bt) -> s/(s^2+b^2)), and linearity for sums and scalar multiples.
Compute the scalar Laplacian of an expression with respect to a list of variables. The Laplacian is the sum of second partial derivatives: Δf = ∂²f/∂x² + ∂²f/∂y² + ...
Find the minimal polynomial of a simple algebraic expression. The minimal polynomial is the monic polynomial with rational coefficients of lowest degree for which the expression is a root. Supports: sqrt(n), cbrt(n), nthRoot(n, k), sqrt(a) + sqrt(b), and rational constants.
Compute the multivariate Taylor series expansion of a scalar expression around a point. Uses mixed partial derivatives to build the polynomial: f + sum_alpha (partial^|alpha| f / alpha!) * prod (xi - ai)^ki, where the sum is over all multi-indices of total degree <= order.
Syntax
multivariateTaylor(expr | variables | points
Type Signatures
string | Node, Array, Array, number
Parameters
Name
Type
Description
expr
string | Node
The scalar expression to expand
variables
Array.<string>
Array of variable names
points
Array.<number>
Array of expansion points (same length as variables)
Solve first-order ordinary differential equations (ODEs) symbolically. The expression is the right-hand side of dy/dx = expr. Handles separable ODEs (dy/dx = g(x)*h(y)) and linear first-order ODEs (dy/dx + P*y = Q(x)) using integrating factors. Returns the general solution with constant C.
Syntax
odeGeneral(expr | y | x)
Parameters
Name
Type
Description
expr
string | Node
Right-hand side of dy/dx = expr
y
string
The dependent variable name
x
string
The independent variable name
Returns
string — General solution as a string (with constant C)
Compute higher-order and mixed partial derivatives of an expression. The variables argument specifies the differentiation order: a single string for first-order, or an array of strings for higher-order mixed partials.
Build and evaluate a piecewise-defined expression. Given an array of [condition, value] pairs and a default value, evaluates each condition in order and returns the value of the first matching condition, or the default if none match.
Expand powers and logarithms assuming arguments are positive real numbers. Distributes (a*b)^n->a^n*b^n, (a^m)^n->a^(m*n), log(a*b)->log(a)+log(b), and similar rules.
Syntax
powerExpand(expr)
Parameters
Name
Type
Description
expr
Node|string
The expression to expand
Returns
Node|string — The expanded expression (same type as input)
Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.
Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.
Syntax
rationalize(expr) | rationalize(expr | scope)
Parameters
Name
Type
Description
expr
Node|string
The expression to check if is a polynomial expression
optional
Object|boolean
scope of expression or true for already evaluated rational expression at input
detailed
Boolean
optional True if return an object, false if return expression node (default)
Returns
Object | Node — The rational polynomial of `expr` or an object
Solve an equation with domain constraints. Calls solve() and filters solutions by the specified domain or by assumptions stored via assume(). Valid domains: Positive, Negative, Nonnegative, Nonzero, Integer, Real, Complex, Rational.
Compute the resultant of two univariate polynomials as the determinant of their Sylvester matrix. The resultant is zero if and only if the polynomials share a common root. Used for polynomial elimination.
Extract the nth coefficient from the Taylor series expansion of an expression around a point. Uses the formula c_n = f^(n)(a) / n! where f^(n) is the nth derivative.
Syntax
seriesCoefficient(expr | variable | point
Type Signatures
string | Node, string, number, number
Parameters
Name
Type
Description
expr
string | Node
The expression to expand
variable
string
The expansion variable
point
number
The expansion point
n
number
The coefficient index (non-negative integer)
Returns
number — The nth Taylor coefficient
Examples
seriesCoefficient("exp(x) x 0 3) seriesCoefficient("sin(x)
Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U
Syntax
slu(A | order | threshold)
Type Signatures
SparseMatrix, number, number
Parameters
Name
Type
Description
A
SparseMatrix
A two dimensional sparse matrix for which to get the LU decomposition.
order
Number
The Symbolic Ordering and Analysis order:
threshold
Number
Partial pivoting threshold (1 for partial pivoting)
Returns
Object — The lower triangular matrix, the upper triangular matrix and the permutation vectors.
Solve an equation or expression equal to zero for a given variable. Handles linear equations, quadratic equations (via quadratic formula), and simple polynomials (rational roots theorem). The input can be an equation like "x^2 - 4 = 0" or just an expression like "x^2 - 4" (treated as equal to zero).
Compute the summation of an expression over a variable from start to end. Attempts closed-form evaluation for common patterns (arithmetic, quadratic, geometric series), then falls back to numeric summation.
Syntax
summation(expr | variable | start
Parameters
Name
Type
Description
expr
string | Node
The summand expression
variable
string
The summation index variable
start
number
The lower bound (integer)
end
number
The upper bound (integer)
Returns
number | string — The sum (number for numeric, string for closed-form)
Compute the product of an expression over a variable from start to end. Attempts closed-form evaluation for common patterns (factorial, partial factorial, constant product), then falls back to numeric evaluation.
Combine fractions over a common denominator. This is the inverse of apart: it takes a sum of fractions and combines them into a single rational expression.
Reduce products of trigonometric functions to sums using product-to-sum identities. Inverse of trigExpand. Applies sin^2, cos^2 half-angle and product formulas.
Syntax
trigReduce(expr)
Parameters
Name
Type
Description
expr
Node|string
The expression to reduce
Returns
Node|string — The reduced expression (same type as input)
Convert trigonometric and hyperbolic functions to exponential form. Applies sin(x)->(exp(i*x)-exp(-i*x))/(2*i), cos(x)->(exp(i*x)+exp(-i*x))/2, and hyperbolic equivalents.
Syntax
trigToExp(expr)
Parameters
Name
Type
Description
expr
Node|string
The expression to convert
Returns
Node|string — The converted expression (same type as input)
Extract all symbolic variable names from an expression. Walks the AST and collects SymbolNode names, excluding known mathematical constants (pi, e, i) and built-in function names. Returns a sorted array of unique variable names.
Compute the Z-transform of a discrete sequence using a lookup table of known transform pairs. Supported: 1 → z/(z-1), n → z/(z-1)^2, n^2 → z*(z+1)/(z-1)^3, a^n → z/(z-a), n*a^n → a*z/(z-a)^2, cos(w*n) and sin(w*n) patterns.
Syntax
zTransform(expr | nVar | zVar)
Parameters
Name
Type
Description
expr
string | Node
The discrete sequence expression (function of nVar)