Arithmetic
Constants
| Symbol | Value | |
|---|---|---|
ExponentialE | \approx 2.7182818284\ldots | Euler's number |
MachineEpsilon | 2^{−52} | The difference between 1 and the next larger floating point number. See Machine Epsilon on Wikipedia |
CatalanConstant | \approx 0.9159655941\ldots | \sum_{n=0}^{\infty} \frac{(-1)^{n}}{(2n+1)^2} See Catalan's Constant on Wikipedia |
GoldenRatio | \approx 1.6180339887\ldots | \frac{1+\sqrt{5}}{2} See Golden Ratio on Wikipedia |
EulerGamma | \approx 0.5772156649\ldots | See Euler-Mascheroni Constant on Wikipedia |
Functions
Arithmetic Functions
| Function | Notation | |
|---|---|---|
Add | a + b | Addition |
Subtract | a - b | Subtraction |
Negate | -a | Additive inverse |
Multiply | a\times b | Multiplication |
Divide | \frac{a}{b} | Divide |
Power | a^b | Exponentiation |
Root | \sqrt[n]{x}=x^{\frac1n} | nth root |
Sqrt | \sqrt{x}=x^{\frac12} | Square root |
Square | x^2 |
Sums and Products
Sum(xs: collection)
Evaluate to a sum of all the elements in collection. If all the elements are
numbers, the result is a number. Otherwise it is an ["Add"] expression.
["Sum", ["List", 5, 7, 11]]
// ➔ 23
["Sum", ["List", 5, 7, "x" , "y"]]
// ➔ ["Add", 12, "x", "y"]
Note this is equivalent to:
["Reduce", ["List", 5, 7, 11], "Add"]
Sum(body: function, ...bounds: tuple) -> number
Evaluate to the sum of body for each value in bounds.
["Sum", ["Add", "i", 1], ["Tuple", "i", 1, 10]]
// ➔ 65
Sum(body: function, ...bounds: Element) -> number
Evaluate to the sum of body for each value in an Element-based indexing set.
This form uses ["Element", index, collection] to specify that the index variable
iterates over a finite collection (Set, List, or Range).
["Sum", "n", ["Element", "n", ["Set", 1, 2, 3]]]
// ➔ 6
["Sum", ["Power", "n", 2], ["Element", "n", ["Set", 1, 2, 3]]]
// ➔ 14 (1² + 2² + 3² = 1 + 4 + 9)
["Sum", "n", ["Element", "n", ["Range", 1, 5]]]
// ➔ 15 (1 + 2 + 3 + 4 + 5)
The indexing set can be:
- Set:
["Set", 1, 2, 3]- explicit finite set of values - List:
["List", 1, 2, 3]- ordered list of values - List (2-element):
["List", 1, 5]- when a List has exactly 2 integer elements, it is treated as a Range. This allows bracket notation like\sum_{n \in [1,5]} nto iterate over all integers from 1 to 5 (evaluates to 15, not 6). - Range:
["Range", 1, 10]- integer range from 1 to 10 - Interval:
["Interval", 1, 10]- enumerates integers in the interval. SupportsOpenandClosedboundary markers:["Interval", 1, 5]→ iterates 1, 2, 3, 4, 5 (closed bounds)["Interval", ["Open", 0], 5]→ iterates 1, 2, 3, 4, 5 (excludes 0)["Interval", 1, ["Open", 6]]→ iterates 1, 2, 3, 4, 5 (excludes 6)
Note: Evaluation requires a finite, enumerable domain with at most 1000 elements.
Sums over infinite sets (like \sum_{n \in \mathbb{N}}) remain symbolic.
Multiple Indexing Sets
Multiple Element expressions can be specified for multi-index sums:
["Sum", ["Multiply", "n", "m"], ["Element", "n", ["Set", 1, 2]], ["Element", "m", ["Set", 3, 4]]]
// ➔ 21 (1·3 + 1·4 + 2·3 + 2·4)
Mixed indexing sets (Element + Limits) can be used together:
["Sum", ["Add", "n", "m"], ["Element", "n", ["Set", 1, 2]], ["Limits", "m", 1, 2]]
// ➔ 12 (n iterates {1,2}, m iterates 1 to 2)
Condition Filtering
A condition can be attached to an Element expression to filter values from the set. The condition is the optional 4th operand of the Element expression.
// Sum only positive values from S
["Sum", "n", ["Element", "n", ["Set", 1, 2, 3, -1, -2], ["Greater", "n", 0]]]
// ➔ 6 (only 1 + 2 + 3)
// Sum values greater than or equal to 2
["Sum", "n", ["Element", "n", ["Set", 1, 2, 3, 4], ["GreaterEqual", "n", 2]]]
// ➔ 9 (only 2 + 3 + 4)
// Product of negative values
["Product", "k", ["Element", "k", ["Set", 1, -2, 3, -4], ["Less", "k", 0]]]
// ➔ 8 (only (-2) × (-4))
Supported condition operators: Greater, GreaterEqual, Less, LessEqual, NotEqual.
Simplification
When simplify() is called on a Sum expression with symbolic bounds, the following closed-form formulas are applied when applicable:
| Pattern | Simplifies to | Name |
|---|---|---|
\sum_{n=1}^{b} c | b \cdot c | Constant body |
\sum_{n=a}^{b} n | \frac{b(b+1) - a(a-1)}{2} | Triangular number (general bounds) |
\sum_{n=1}^{b} n^2 | \frac{b(b+1)(2b+1)}{6} | Sum of squares |
\sum_{n=1}^{b} n^3 | \left[\frac{b(b+1)}{2}\right]^2 | Sum of cubes |
\sum_{n=0}^{b} r^n | \frac{1-r^{b+1}}{1-r} | Geometric series |
\sum_{n=0}^{b} (-1)^n | \frac{1+(-1)^b}{2} | Alternating unit series |
\sum_{n=0}^{b} (-1)^n \cdot n | (-1)^b \lfloor\frac{b+1}{2}\rfloor | Alternating linear series |
\sum_{n=0}^{b} (a + dn) | (b+1)\left(a + \frac{db}{2}\right) | Arithmetic progression |
\sum_{k=0}^{n} \binom{n}{k} | 2^n | Sum of binomial coefficients |
\sum_{k=0}^{n} (-1)^k \binom{n}{k} | 0 | Alternating binomial sum |
\sum_{k=0}^{n} k \binom{n}{k} | n \cdot 2^{n-1} | Weighted binomial sum |
\sum_{k=1}^{n} \frac{1}{k(k+1)} | \frac{n}{n+1} | Partial fractions (telescoping) |
\sum_{k=2}^{n} \frac{1}{k(k-1)} | \frac{n-1}{n} | Partial fractions (telescoping) |
\sum_{k=0}^{n} k^2 \binom{n}{k} | n(n+1) \cdot 2^{n-2} | Weighted squared binomial sum |
\sum_{k=0}^{n} k^3 \binom{n}{k} | n^2(n+3) \cdot 2^{n-3} | Weighted cubed binomial sum |
\sum_{k=0}^{n} (-1)^k k \binom{n}{k} | 0 | Alternating weighted binomial sum (n ≥ 2) |
\sum_{k=0}^{n} \binom{n}{k}^2 | \binom{2n}{n} | Sum of binomial squares |
\sum_{k=1}^{n} k(k+1) | \frac{n(n+1)(n+2)}{3} | Sum of consecutive products |
\sum_{n=m}^{b} (a + dn) | (b-m+1)\left(a + \frac{d(m+b)}{2}\right) | Arithmetic progression (general bounds) |
\sum_{n=1}^{b} c \cdot f(n) | c \cdot \sum_{n=1}^{b} f(n) | Factor out constant |
Edge cases:
- Empty range (upper < lower): returns
0 - Single iteration (upper = lower): substitutes the bound value and returns the body
- Nested sums: inner sums are simplified first, enabling cascading simplification
Product(xs: collection)
Evaluate to a product of all the elements in collection.
If all the elements are numbers, the result is a number. Otherwise it is a ["Multiply"] expression.
["Product", ["List", 5, 7, 11]]
// ➔ 385
["Product", ["List", 5, "x", 11]]
// ➔ ["Multiply", 55, "x"]
Note this is equivalent to:
["Reduce", ["List", 5, 7, 11], "Multiply"]
Product(f: function, bounds:tuple)
Return the product of body for each value in bounds.
["Product", ["Add", "x", 1], ["Tuple", "x", 1, 10]]
// ➔ 39916800
Product(body: function, ...bounds: Element) -> number
Evaluate to the product of body for each value in an Element-based indexing set.
This form uses ["Element", index, collection] to specify that the index variable
iterates over a finite collection (Set, List, or Range).
["Product", "k", ["Element", "k", ["Set", 1, 2, 3, 4]]]
// ➔ 24 (4!)
["Product", ["Power", "k", 2], ["Element", "k", ["Set", 1, 2, 3]]]
// ➔ 36 (1² × 2² × 3² = 1 × 4 × 9)
See the Sum documentation above for details on supported collection types.
Simplification
When simplify() is called on a Product expression with symbolic bounds, the following closed-form formulas are applied when applicable:
| Pattern | Simplifies to | Name |
|---|---|---|
\prod_{n=1}^{b} c | c^b | Constant body |
\prod_{n=1}^{b} n | b! | Factorial |
\prod_{n=1}^{b} (n+c) | \frac{(b+c)!}{c!} | Shifted factorial |
\prod_{n=1}^{b} (2n-1) | (2b-1)!! | Odd double factorial |
\prod_{n=1}^{b} 2n | 2^b \cdot b! | Even double factorial |
\prod_{k=0}^{n-1} (x+k) | (x)_n | Rising factorial (Pochhammer) |
\prod_{k=0}^{n-1} (x-k) | \frac{x!}{(x-n)!} | Falling factorial |
\prod_{k=1}^{n} \frac{k+1}{k} | n+1 | Telescoping product |
\prod_{k=2}^{n} (1 - \frac{1}{k^2}) | \frac{n+1}{2n} | Wallis-like product |
\prod_{n=1}^{b} c \cdot f(n) | c^b \cdot \prod_{n=1}^{b} f(n) | Factor out constant |
Edge cases:
- Empty range (upper < lower): returns
1 - Single iteration (upper = lower): substitutes the bound value and returns the body
Transcendental Functions
| Function | Notation | |
|---|---|---|
Exp | \exponentialE^{x} | Exponential function |
Ln | \ln(x) | Logarithm function, the natural logarithm, the inverse of Exp |
Log | \log_b(x) | ["Log", <v>, <b>]Logarithm of base b, default 10 |
Lb | \log_2(x) | Binary logarithm function, the base-2 logarithm |
Lg | \log_{10}(x) | Common logarithm, the base-10 logarithm |
LogOnePlus | \ln(x+1) |
Rounding
| Function | Notation | |
|---|---|---|
Abs | \|x\| | Absolute value, magnitude |
Ceil | \lceil x \rceil | Rounds a number up to the next largest integer |
Floor | \lfloor x \rfloor | Round a number to the greatest integer less than the input value |
Chop | Replace real numbers that are very close to 0 (less than 10^{-10}) with 0 | |
Round |
Other Relational Operators
Congruent(a, b, modulus)
Evaluate to True if a is congruent to b modulo modulus.
["Congruent", 26, 11, 5]
// ➔ True
Other Functions
Clamp(value)
Clamp(value, lower, upper)
- If
valueis less thanlower, evaluate tolower - If
valueis greater thanupper, evaluate toupper - Otherwise, evaluate to
value
If lowerand upperare not provided, they take the default values of -1 and
+1.
["Clamp", 0.42]
// ➔ 1
["Clamp", 4.2]
// ➔ 1
["Clamp", -5, 0, "+Infinity"]
// ➔ 0
["Clamp", 100, 0, 11]
// ➔ 11
Max(x1, x2, ...)
Max(list)
If all the arguments are real numbers, excluding NaN, evaluate to the largest
of the arguments.
Otherwise, simplify the expression by removing values that are smaller than or equal to the largest real number.
["Max", 5, 2, -1]
// ➔ 5
["Max", 0, 7.1, "NaN", "x", 3]
// ➔ ["Max", 7.1, "NaN", "x"]
Max(x1, x2, ...)
Max(list)
If all the arguments are real numbers, excluding NaN, evaluate to the smallest
of the arguments.
Otherwise, simplify the expression by removing values that are greater than or equal to the smallest real number.
["Min", 5, 2, -1]
// ➔ -1
["Min", 0, 7.1, "x", 3]
// ➔ ["Min", 0, "x"]
Mod(a, b)
Evaluate to the Euclidian division (modulus) of a by b.
When a and b are positive integers, this is equivalent to the % operator in
JavaScript, and returns the remainder of the division of a by b.
However, when a and b are not positive integers, the result is different.
The result is always the same sign as b, or 0.
["Mod", 7, 5]
// ➔ 2
["Mod", -7, 5]
// ➔ 3
["Mod", 7, -5]
// ➔ -3
["Mod", -7, -5]
// ➔ -2
Rational(n)
Evaluate to a rational approximating the value of the number n.
["Rational", 0.42]
// ➔ ["Rational", 21, 50]
Rational(numerator, denominator)
Represent a rational number equal to numeratorover denominator.
Numerator(expr)
Return the numerator of expr.
Note that expr may be a non-canonical form.
["Numerator", ["Rational", 4, 5]]
// ➔ 4
Denominator(expr)
Return the denominator of expr.
Note that expr may be a non-canonical form.
["Denominator", ["Rational", 4, 5]]
// ➔ 5
NumeratorDenominator(expr)
Return the numerator and denominator of expr as a sequence.
Note that expr may be a non-canonical form.
["NumeratorDenominator", ["Rational", 4, 5]]
// ➔ ["Sequence", 4, 5]
The sequence can be used with another function, for example GCD to check if the fraction is in its canonical form:
["GCD", ["NumeratorDenominator", ["Rational", 4, 5]]]
// ➔ 1
["GCD", ["NumeratorDenominator", ["Rational", 8, 10]]]
// ➔ 2
Relational Operators
| Function | Notation | |
|---|---|---|
Equal | x = y | Mathematical relationship asserting that two quantities have the same value |
NotEqual | x \ne y | |
Greater | x \gt y | |
GreaterEqual | x \geq y | |
Less | x \lt y | |
LessEqual | x \leq y |
See below for additonal relational operators: Congruent, etc...
Polynomial Arithmetic
These functions operate on polynomial expressions.
| Function | Description |
|---|---|
Expand | Expand products and positive integer powers |
ExpandAll | Recursively expand products and positive integer powers |
Factor | Factor an expression into irreducible factors |
Together | Combine rational expressions into a single fraction |
Distribute | Distribute multiplication over addition |
PolynomialDegree | Return the degree of a polynomial |
CoefficientList | Return the list of coefficients of a polynomial |
Polynomial | Construct a polynomial from a coefficient list |
PolynomialQuotient | Return the quotient of polynomial division |
PolynomialRemainder | Return the remainder of polynomial division |
GCD | Greatest common divisor of integers or polynomials |
PolynomialGCD | Return the greatest common divisor of two polynomials |
Cancel | Cancel common polynomial factors in a rational expression |
PartialFraction | Decompose a rational expression into partial fractions |
Apart | Alias for PartialFraction |
PolynomialRoots | Return the roots of a polynomial |
Discriminant | Return the discriminant of a polynomial |
Expand(expr)
Expand out products and positive integer powers in expr.
["Expand", ["Power", ["Add", "x", 1], 2]]
// ➔ ["Add", ["Power", "x", 2], ["Multiply", 2, "x"], 1]
ExpandAll(expr)
Recursively expand out products and positive integer powers in expr and all subexpressions.
Factor(expr)
Factor(expr, var)
Factor a polynomial expression into a product of irreducible factors.
Supports:
- Perfect square trinomials:
a^2 \pm 2ab + b^2 \to (a \pm b)^2 - Difference of squares:
a^2 - b^2 \to (a-b)(a+b) - Quadratic factoring:
ax^2 + bx + c(when roots are rational) - Rational root factoring: Degree 3+ polynomials with rational roots (via Rational Root Theorem)
- Content extraction:
6x^2 + 12x + 6 \to 6(x+1)^2(extracts GCD of integer coefficients first) - Common factor extraction:
2x + 4 \to 2(x+2)
The optional var parameter specifies which variable to factor over.
Perfect square trinomial:
["Factor", ["Add", ["Power", "x", 2], ["Multiply", 2, "x"], 1]]
// ➔ ["Power", ["Add", "x", 1], 2] // (x+1)²
Quadratic with rational roots:
["Factor", ["Add", ["Power", "x", 2], ["Multiply", 5, "x"], 6]]
// ➔ ["Multiply", ["Add", "x", 2], ["Add", "x", 3]] // (x+2)(x+3)
Difference of squares:
["Factor", ["Add", ["Power", "x", 2], -4]]
// ➔ ["Multiply", ["Add", "x", -2], ["Add", "x", 2]] // (x-2)(x+2)
A difference of squares is factored recursively, so a higher-degree input such
as x^6 - 1 is reduced all the way to its irreducible (cyclotomic) factors
rather than stopping at the first split:
["Factor", ["Subtract", ["Power", "x", 6], 1]]
// ➔ (x-1)(x+1)(x²+x+1)(x²-x+1)
The factors are always polynomials: Factor never introduces Sqrt or Abs
(e.g. x^3 - 1 \to (x-1)(x^2+x+1), not the branch-dependent
(x\sqrt{x}-1)(x\sqrt{x}+1)).
With coefficients:
["Factor", ["Add", ["Multiply", 4, ["Power", "x", 2]], ["Multiply", 12, "x"], 9]]
// ➔ ["Power", ["Add", ["Multiply", 2, "x"], 3], 2] // (2x+3)²
Cubic with rational roots:
["Factor", ["Add", ["Power", "x", 3], ["Negate", ["Multiply", 6, ["Power", "x", 2]]], ["Multiply", 11, "x"], -6]]
// ➔ ["Multiply", ["Add", "x", -1], ["Add", "x", -2], ["Add", "x", -3]] // (x-1)(x-2)(x-3)
Automatic use in sqrt simplification:
["Sqrt", ["Add", ["Power", "x", 2], ["Multiply", 2, "x"], 1]]
// ➔ ["Abs", ["Add", "x", 1]] // |x+1| (auto-factors before applying sqrt rule)
Together(expr)
Combine rational expressions into a single fraction with a common denominator.
["Together", ["Add", ["Divide", 1, "x"], ["Divide", 1, "y"]]]
// ➔ ["Divide", ["Add", "x", "y"], ["Multiply", "x", "y"]]
Distribute(expr)
Distribute multiplication over addition in expr.
["Distribute", ["Multiply", "a", ["Add", "b", "c"]]]
// ➔ ["Add", ["Multiply", "a", "b"], ["Multiply", "a", "c"]]
PolynomialDegree(poly, var)
Return the degree of the polynomial poly with respect to the variable var.
["PolynomialDegree", ["Add", ["Power", "x", 3], ["Multiply", 2, "x"], 1], "x"]
// ➔ 3
CoefficientList(poly, var)
Return the list of coefficients of the polynomial poly with respect to the variable var, ordered from highest to lowest degree.
["CoefficientList", ["Add", ["Power", "x", 3], ["Multiply", 2, "x"], 1], "x"]
// ➔ ["List", 1, 0, 2, 1]
The result represents the polynomial 1 \cdot x^3 + 0 \cdot x^2 + 2 \cdot x + 1. The first element is the leading coefficient, and the last element is the constant term.
This function is also available as a method on expressions:
const coeffs = ce.parse('x^3 + 2x + 1').polynomialCoefficients('x');
// ➔ [1, 0, 2, 1] (as BoxedExpression[])
When the variable is omitted, it is auto-detected if the expression has exactly one unknown:
ce.parse('x^2 + 5').polynomialCoefficients();
// ➔ [1, 0, 5]
Returns undefined if the expression is not a polynomial in the given variable. This subsumes an isPolynomial check and degree computation:
const isPolynomial = expr.polynomialCoefficients('x') !== undefined;
const degree = expr.polynomialCoefficients('x')?.length - 1;
Multivariate validation: Pass an array of variables to validate that the expression is polynomial in all of them. The coefficients are decomposed by the first variable:
ce.parse('x^2*y + 3x + y^2').polynomialCoefficients(['x', 'y']);
// ➔ [y, 3, y²] (polynomial in both x and y, decomposed by x)
ce.parse('sin(x)*y + 1').polynomialCoefficients(['x', 'y']);
// ➔ undefined (not polynomial in x)
polynomialRoots()
The polynomialRoots() method returns the roots of a polynomial expression:
ce.parse('x^2 - 5x + 6').polynomialRoots('x');
// ➔ [2, 3]
ce.parse('x^3 - 6x^2 + 11x - 6').polynomialRoots('x');
// ➔ [1, 2, 3]
ce.parse('x^2 + 1').polynomialRoots('x');
// ➔ [] (no real roots)
ce.parse('sin(x)').polynomialRoots('x');
// ➔ undefined (not a polynomial)
Returns undefined if the expression is not a polynomial. Returns an empty array if no roots can be found (e.g., irreducible over the rationals). Supports auto-detection of the variable when omitted.
Polynomial(coefficients, var)
Construct a polynomial expression from a list of coefficients (highest degree first) and a variable. This is the inverse of CoefficientList.
["Polynomial", ["List", 1, 0, 2, 1], "x"]
// ➔ ["Add", ["Power", "x", 3], ["Multiply", 2, "x"], 1]
This constructs the polynomial x^3 + 2x + 1 from the coefficient list [1, 0, 2, 1].
Round-trip with CoefficientList:
\operatorname{Polynomial}(\operatorname{CoefficientList}(p, x), x) = p
PolynomialQuotient(dividend, divisor, var)
Return the quotient of the polynomial division of dividend by divisor with respect to the variable var.
["PolynomialQuotient", ["Subtract", ["Power", "x", 3], 1], ["Subtract", "x", 1], "x"]
// ➔ ["Add", ["Power", "x", 2], "x", 1]
This represents \frac{x^3 - 1}{x - 1} = x^2 + x + 1.
PolynomialRemainder(dividend, divisor, var)
Return the remainder of the polynomial division of dividend by divisor with respect to the variable var.
["PolynomialRemainder", ["Add", ["Power", "x", 3], ["Multiply", 2, "x"], 1], ["Add", "x", 1], "x"]
// ➔ -2
GCD(x-1, x-2, ...)
Return the greatest common divisor of the arguments.
With integer arguments, GCD returns their integer greatest common divisor:
["GCD", 60, 12, 18]
// ➔ 6
GCD also computes the greatest common divisor of polynomials. When the
arguments are univariate polynomials in the same variable that share a
non-trivial common factor, the variable is inferred and a (monic) polynomial
GCD is returned:
["GCD",
["Add", ["Power", "x", 2], ["Multiply", 3, "x"], 2],
["Add", ["Power", "x", 2], ["Multiply", 4, "x"], 3]]
// ➔ ["Add", "x", 1]
This represents \gcd(x^2 + 3x + 2, x^2 + 4x + 3) = x + 1.
When the polynomial GCD would be a constant, the expression is left
unevaluated, so that a bare symbol keeps its integer-GCD reading — for example
["GCD", "x", 6] (where x may stand for an unknown integer) stays symbolic.
Use PolynomialGCD with an explicit variable when you want the coprime
→ 1 result, or to control which variable the GCD is taken over.
PolynomialGCD(a, b, var)
Return the greatest common divisor of two polynomials a and b with respect to the variable var.
["PolynomialGCD", ["Subtract", ["Power", "x", 2], 1], ["Subtract", "x", 1], "x"]
// ➔ ["Subtract", "x", 1]
This represents \gcd(x^2 - 1, x - 1) = x - 1.
Cancel(expr, var)
Cancel common polynomial factors in the numerator and denominator of the rational expression expr with respect to the variable var.
["Cancel", ["Divide", ["Subtract", ["Power", "x", 2], 1], ["Subtract", "x", 1]], "x"]
// ➔ ["Add", "x", 1]
This represents \frac{x^2 - 1}{x - 1} = x + 1 after canceling the common factor (x - 1).
PartialFraction(expr, var)
Decompose a rational expression into a sum of simpler fractions (partial fractions) with respect to the variable var.
Supports:
- Distinct linear factors:
\frac{1}{(x+1)(x+2)} \to \frac{1}{x+1} - \frac{1}{x+2} - Repeated linear factors:
\frac{3x+5}{(x+1)^2} \to \frac{3}{x+1} + \frac{2}{(x+1)^2} - Irreducible quadratic factors:
\frac{1}{(x+1)(x^2+1)} \to \frac{1}{2(x+1)} + \frac{-x+1}{2(x^2+1)} - Improper fractions: Performs polynomial division first, then decomposes the proper remainder.
Returns the expression unchanged if it is not a rational expression in var, or if the denominator cannot be factored.
["PartialFraction", ["Divide", 1, ["Multiply", ["Add", "x", 1], ["Add", "x", 2]]], "x"]
// ➔ ["Add", ["Divide", 1, ["Add", "x", 1]], ["Divide", -1, ["Add", "x", 2]]]
Apart(expr, var)
Alias for PartialFraction. Decompose a rational expression into partial fractions.
PolynomialRoots(poly, var)
Return the roots of the polynomial poly with respect to the variable var as a set.
Returns undefined if the expression is not a polynomial or no roots can be found. Supports polynomials up to degree 4 with rational roots, and degree 2 with irrational roots.
["PolynomialRoots", ["Add", ["Power", "x", 2], ["Multiply", -5, "x"], 6], "x"]
// ➔ ["Set", 2, 3]
Discriminant(poly, var)
Return the discriminant of the polynomial poly with respect to the variable var. Supports degree 2, 3, and 4 polynomials. Works with symbolic coefficients.
- Degree 2 (
ax^2 + bx + c): returnsb^2 - 4ac - Degree 3 (
ax^3 + bx^2 + cx + d): returnsb^2c^2 - 4ac^3 - 4b^3d + 18abcd - 27a^2d^2 - Degree 4: returns the full 16-term discriminant formula
["Discriminant", ["Add", ["Power", "x", 2], ["Multiply", -5, "x"], 6], "x"]
// ➔ 1
A discriminant of 0 indicates repeated roots. For quadratics, a negative discriminant indicates no real roots.