ReadonlykeysThe keys of the dictionary.
If this expression not a dictionary, return null
ReadonlykeysIf this expression is a dictionary, return the value of the key entry.
If this expression is a dictionary, return true if the
dictionary has a key entry.
ReadonlyisThe value of this expression is a number that is the root of a non-zero univariate polynomial with rational coefficients.
All integers and rational numbers are algebraic.
Transcendental numbers, such as \( \pi \) or \( e \) are not algebraic.
ReadonlyisThe value of this expression is a number, but not NaN or any Infinity
isReal || isImaginary
ReadonlyisisReal || isImaginary || isInfinity
ReadonlyisReal or ±Infinity
isReal || isInfinity
ReadonlyisThe value of this expression is a number with a imaginary part
ReadonlyisThe value of this expression is an element of the set ℤ: ...,-2, -1, 0, 1, 2...
Readonlyistrue if the value of this expression is a number.
isExtendedComplex || isNaN = isReal || isImaginary || isInfinity || isNaN
Note that in a fateful twist of cosmic irony, NaN ("Not a Number")
is a number.
ReadonlyisThe value of this expression is an element of the set ℚ, p/q with p ∈ ℕ, q ∈ ℤ ⃰ q >= 1
Note that every integer is also a rational.
ReadonlyisThe value of this expression is real number: finite and not imaginary.
isFinite && !isImaginary
ReadonlyisReadonlyisReadonlyisThis expression is a number, but not ±Infinity and not NaN
ReadonlyisThe numeric value of this expression is ±Infinity or Complex Infinity
Readonlyis"Not a Number".
A value representing undefined result of computations, such as 0/0,
as per the floating point format standard IEEE-754.
Note that if isNaN is true, isNumber is also true (yes, NaN is a
number).
ReadonlyisThe numeric value of this expression is < 0, same as isLess(0)
ReadonlyisThe numeric value of this expression is not -1.
ReadonlyisThe numeric value of this expression is >= 0, same as isGreaterEqual(0)
ReadonlyisThe numeric value of this expression is <= 0, same as isLessEqual(0)
ReadonlyisThe numeric value of this expression is not 0.
ReadonlyisReadonlyisThe numeric value of this expression is not 1.
ReadonlyisThe numeric value of this expression is > 0, same as isGreater(0)
ReadonlyisReadonlyisThe numeric value of this expression is 0.
ReadonlynopsIf this expression is a function, the number of operands, otherwise 0.
Note that a function can have 0 operands, so to check if this expression
is a function, check if this.ops !== null instead.
Note applicable to canonical and non-canonical expressions.
Readonlyop1First operand, i.e.this.ops[0]
Note applicable to canonical and non-canonical expressions.
Readonlyop2Second operand, i.e.this.ops[1]
Note applicable to canonical and non-canonical expressions.
Readonlyop3Third operand, i.e. this.ops[2]
Note applicable to canonical and non-canonical expressions.
ReadonlyopsThe list of arguments of the function, its "tail".
If the expression is not a function, return null.
Note applicable to canonical and non-canonical expressions.
ReadonlynumericReturn the value of this expression, if a number literal.
Note it is possible for numericValue to be null, and for isNotZero
to be true. For example, when a symbol has been defined with an assumption.
Conversely, isNumber may be true even if numericValue is null,
example the symbol Pi return true for isNumber but numericValue is
null. It's value can be accessed with .value.numericValue
ReadonlysgnReturn the following, depending on the value of this expression:
-1 if it is < 00 if it is = 0+1 if it is > 0undefined this value may be positive, negative or zero. We don't know
right now (a symbol with an Integer domain, but no currently assigned
value, for example)null this value will never be positive, negative or zero (NaN,
a string or a complex number for example)Note that complex numbers have no natural ordering,
so if the value is a complex number, sgn is either 0, or null
If a symbol, this does take assumptions into account, that is this.sgn
will return 1 if isPositive is true, even if this expression has
no value
ReadonlybaseFor symbols and functions, a possible definition associated with the
expression. baseDefinition is the base class of symbol and function
definition.
Note undefined if not a canonical expression.
ReadonlycomplexityExpressions with a higher complexity score are sorted first in commutative functions
Note undefined if not a canonical expression.
ReadonlydescriptionAn optional short description if a symbol or function expression.
May include markdown. Each string is a paragraph.
Note undefined if not a canonical expression.
ReadonlyengineThe Compute Engine associated with this expression provides a context in which to interpret it, such as definition of symbols and functions.
ComputeEngine is the class that implements IComputeEngine.
ReadonlyerrorsAll the ["Error"] subexpressions
Note applicable to canonical and non-canonical expressions.
ReadonlyfreeAll the identifiers (symbols and functions) in the expression that are not a local variable or a parameter of that function.
ReadonlyfunctionFor functions, a possible definition associated with the expression.
Note undefined if not a canonical expression or not a function.
Readonly InternalhashReadonlyheadAll boxed expressions have a head.
If not a function this can be Symbol, String, Number or Dictionary.
If the head expression can be represented as a string, it is returned as a string.
Note applicable to canonical and non-canonical expressions. The head
of a non-canonical expression may be different than the head of its
canonical counterpart. For example the canonical counterpart of ["Divide", 5, 7] is ["Rational", 5, 5].
ReadonlyisTrue if the expression is a constant, that is a symbol with an immutable value
ReadonlyisAn exact value is not further transformed when evaluated. To get an
approximate evaluation of an exact value, use .N().
Non-exact values includes:
ReadonlyisIf this is the Nothing symbol, return true.
Note applicable to canonical and non-canonical expressions.
ReadonlyisIf true, the value of the expression never changes and evaluating it has no side-effects. If false, the value of the expression may change, if the value of other expression changes or for other reasons.
If this.isPure is false, this.value is undefined. Call
this.evaluate() to determine the value of the expression instead.
As an example, the Random function is not pure.
Note applicable to canonical and non-canonical expressions.
ReadonlyjsonMathJSON representation of this expression.
Note applicable to canonical and non-canonical expressions.
ReadonlyrankReturn 0 for a scalar, 1 for a vector, 2 for a matrix, > 2 for a multidimensional matrix. It's the length of expr.shape
Readonly InternalrawFor debugging, the raw MathJSON representation of this expression without decanonicalization.
ReadonlyscopeThe scope in which this expression has been defined. Is null when the expression is not canonical.
ReadonlyshapeThe shape describes the axis of the expression.
When the expression is a scalar (number), the shape is [].
When the expression is a vector, the shape is [n].
When the expression is a matrix, the shape is [n, m].
ReadonlysubexpressionsAll the subexpressions in this expression, recursively
Note applicable to canonical and non-canonical expressions.
ReadonlysymbolFor symbols, a possible definition associated with the expression.
Note undefined if not a symbol
ReadonlysymbolsAll the symbols in the expression, recursively
Note applicable to canonical and non-canonical expressions.
ReadonlyunknownsAll the identifiers used in the expression that do not have a value associated with them, i.e. they are declared but not defined.
ReadonlyurlAn optional URL pointing to more information about the symbol or function head.
Note undefined if not a canonical expression.
ReadonlywikidataWikidata identifier.
Note undefined if not a canonical expression.
Return the canonical form of this expression.
If this is a function expressin, a definition is associated with the canonical expression.
When determining the canonical form the following function definition flags are applied:
associative: \( f(a, f(b), c) \longrightarrow f(a, b, c) \)idempotent: \( f(f(a)) \longrightarrow f(a) \)involution: \( f(f(a)) \longrightarrow a \)commutative: sort the arguments.If his expression is already canonical, the value of canonical is
this.
The domain of the value of this expression.
If a function expression, the domain of the value of the function (the codomain of the function).
If a symbol the domain of the value of the symbol.
Use expr.head to determine if an expression is a symbol or function
expression.
Note: if non-canonical or not valid, return undefined.
Modify the domain of a symbol.
Note: If non-canonical, does nothing.
If true, this expression is in a canonical form.
Note applicable to canonical and non-canonical expressions.
InternalFor internal use only, set when a canonical expression is created.
LaTeX representation of this expression.
The serialization can be customized with ComputeEngine.latexOptions
Note applicable to canonical and non-canonical expressions.
InternalNote applicable to canonical and non-canonical expressions.
Return a JavaScript primitive representing the value of this expression.
Equivalent to expr.N().valueOf().
Only the value of variables can be changed (symbols that are not constants).
Throws a runtime error if a constant.
Note: If non-canonical, does nothing.
InternalUpdate the definition associated with this expression, using the
current scope (ce.context).
Return the number of exprs that matched the pattern
Optionaloptions: PatternMatchOptionsReturn the value of the canonical form of this expression.
A pure expression always return the same value and has no side effects.
If expr.isPure is true, expr.value and expr.evaluate() are
synonyms.
For an impure expression, expr.value is undefined.
Evaluating an impure expression may have some side effects, for
example modifying the ComputeEngine environment, such as its set of
assumptions.
Only exact calculations are performed, no approximate calculations on decimal numbers (non-integer numbers). Constants, rational numbers and square root of rational numbers are preserved.
To perform approximate calculations, use expr.N() instead.
The result of expr.evaluate() may be the same as expr.simplify().
The result is in canonical form.
Optionaloptions: EvaluateOptionsAll the subexpressions matching the head
Note applicable to canonical and non-canonical expressions.
True if the expression includes a symbol v or a function head v.
Note applicable to canonical and non-canonical expressions.
InternalInfer the domain of this expression.
If the domain of this expression is already known, return false.
If the domain was not set, set it to the inferred domain, return true
If the domain was previously inferred, adjust it by widening it,
return true
Attempt to match this expression to the rhs expression.
If rhs does not match, return null.
Otherwise return an object literal.
If this expression includes wildcards (symbols with a name that starts
with _), the object literal will include a prop for each matching named
wildcard.
If rhs matches this pattern but there are no named wildcards, return
the empty object literal, {}.
Note applicable to canonical and non-canonical expressions.
Optionaloptions: PatternMatchOptionsReturn a numeric approximation of the canonical form of this expression.
Any necessary calculations, including on decimal numbers (non-integers), are performed.
The calculations are performed according to the numericMode and
precision properties of the ComputeEngine.
To only perform exact calculations, use this.evaluate() instead.
If the function is not numeric, the result of this.N() is the same as
this.evaluate().
The result is in canonical form.
Optionaloptions: NOptionsTransform the expression by applying the rules:
if the lhs of a rule matches, it is replaced by its rhs.
If no rules apply, return null.
See also subs for a simple substitution.
Note applicable to canonical and non-canonical expressions.
Optionaloptions: ReplaceOptionsInternalReset the cached value associated with this expression.
Use when the environment has changed, for example the numeric mode or precision, to force the expression to be re-evaluated.
Return a simpler form of the canonical form of this expression.
A series of rewriting rules are applied repeatedly, until no more rules apply.
If a custom simplify handler is associated with this function
definition, it is invoked.
The values assigned to symbols and the assumptions about symbols may be
used, for example arg.isInteger or arg.isPositive.
No calculations involving decimal numbers (numbers that are not integers) are performed but exact calculations may be performed, for example:
\( \sin(\frac{\pi}{4}) \longrightarrow \frac{\sqrt{2}}{2} \).
The result is in canonical form.
Optionaloptions: SimplifyOptionsReplace all the symbols in the expression as indicated.
Note the same effect can be achieved with this.replace(), but
using this.subs() is more efficient, and simpler.
Note applicable to canonical and non-canonical expressions.
Optionaloptions: { canonical?: boolean }If expr matches the pattern, return true, otherwise false
Optionaloptions: PatternMatchOptionsSimilar toexpr.valueOf() but includes a hint.
From Object.is(). Equivalent to BoxedExpression.isSame()
Output to the console a string representation of the expression.
Used by JSON.stringify() to serialize this object to JSON.
Method version of expr.json.
From Object.toString(), return a string representation of the
expression. This string is suitable to be output to the console
for debugging, for example. To get a LaTeX representation of the
expression, use expr.latex.
Used when coercing a BoxedExpression to a String.
From Object.valueOf(), return a primitive value for the expression.
If the expression is a machine number, or bignum or rational that can be
converted to a machine number, return a JavaScript number.
If the expression is a symbol, return the name of the symbol as a string.
Otherwise return a JavaScript primitive representation of the expression.
Mathematical equality (strong equality), that is the value
of this expression and of rhs are numerically equal.
The numeric value of both expressions are compared.
Numbers whose difference is less than engine.tolerance are
considered equal. This tolerance is set when the engine.precision is
changed to be such that the last two digits are ignored.
The numeric value of both expressions are compared.
The numeric value of both expressions are compared.
If the expressions cannot be compared, return undefined
The numeric value of both expressions are compared.
The numeric value of both expressions are compared.
Structural/symbolic equality (weak equality).
ce.parse('1+x').isSame(ce.parse('x+1')) is false
Note applicable to canonical and non-canonical expressions.
ReadonlystringIf this expression is a string, return the value of the string.
Otherwise, return null.
Note applicable to canonical and non-canonical expressions.
Readonlyistrue if this expression or any of its subexpressions is an ["Error"]
expression.
Note applicable to canonical and non-canonical expressions. For non-canonical expression, this may indicate a syntax error while parsing LaTeX. For canonical expression, this may indicate argument domain mismatch, or missing or unexpected arguments.
ReadonlysymbolIf this expression is a symbol, return the name of the symbol as a string.
Otherwise, return null.
Note applicable to canonical and non-canonical expressions.
THEORY OF OPERATIONS
The
BoxedExpressioninterface includes most of the member functions applicable to any kind of expression, for exampleget symbol()orget ops().When a member function is not applicable to this
BoxedExpression, for exampleget symbol()on aBoxedNumber, it returnsnull.This convention makes it convenient to manipulate expressions without having to check what kind of instance they are before manipulating them.