Expression methods
Single-subject operations (transforms, calculus, solving, output) are also
available directly as methods on Expression — e.simplify(),
e.integrate("x"), e.solve("x"), e.to_latex(), … — delegating to the
context the expression belongs to. The entries in the operation chapters
document parameters and semantics; the method form drops the leading
expression argument. Exact input conversion and context ownership are
specified in Conversions and collections and
Context safety.
is_stale#
Raw WebAssembly: Expression method
isStale(): booleanReports whether resetting the owning context invalidated the expression. All other operations reject a stale receiver with an actionable error.
Arithmetic#
Python uses the native operators + - * / ** -; operands may be expressions,
integers, or exact fractions. JavaScript uses the equivalent named methods and
accepts facade expressions, bigint, and safe integral number values. All
route through the auto-simplifying builders.
add#
Expression method
add(other: ExpressionLike): Expressionsubtract#
Expression method
subtract(other: ExpressionLike): ExpressionCalling forms
Raw WebAssembly: Expression method: Expression.subtract
subtract(other: Expression): Expressionmultiply#
Expression method
multiply(other: ExpressionLike): ExpressionCalling forms
Raw WebAssembly: Expression method: Expression.multiply
multiply(other: Expression): Expressiondivide#
Expression method
divide(other: ExpressionLike): ExpressionCalling forms
Raw WebAssembly: Expression method: Expression.divide
divide(other: Expression): Expressionpower#
Expression method
power(exponent: ExpressionLike): ExpressionCalling forms
Raw WebAssembly: Expression method: Expression.power
power(exponent: Expression): Expressionnegate#
Expression method
negate(): ExpressionSubstitution and structure#
substitute#
Raw WebAssembly: Expression method
substitute(variable: string, value: Expression): ExpressionReplace every free occurrence of the named symbol with value, re-running
auto-simplification.
rewrite_in_terms_of#
Raw WebAssembly: Default context
rewriteInTermsOf(
target: Expression,
source: Expression,
replacement: Expression,
): ExpressionCalling forms
Raw WebAssembly: Explicit context: Context.rewriteInTermsOf
rewriteInTermsOf(
target: Expression,
source: Expression,
replacement: Expression,
): ExpressionRaw WebAssembly: Expression method: Expression.rewriteInTermsOf
rewriteInTermsOf(
source: Expression,
replacement: Expression,
): ExpressionRewrite the target in terms of replacement under the caller-supplied formal
relation replacement = source. Exact subtrees, canonical additive and
multiplicative extractions, integer exponential families, and positive
same-base power families are supported. Every inferred match is accepted only
when substituting source back exactly reconstructs the matched target.
Fractional exponential relations and branch-sensitive power identities
conservatively remain unchanged. To introduce a displayed name such as z,
pass symbol("z") as replacement; assigning the source expression to a
host-language variable named z does not create a symbolic name.
free_variables#
Not exposed by the WASM / JavaScript bindings. Available as Expression.free_variables in Python, UniffiExpression.freeVariables in Kotlin, UniffiExpression.freeVariables in Swift, api::Expression::free_variables in Rust.
Sorted names of the free symbols. Bound binders (integration variables, image-set parameters) are excluded; the constants pi/e are not symbols.
expression_type#
Not exposed by the WASM / JavaScript bindings. Available as Expression.expression_type in Python, UniffiExpression.expressionType in Kotlin, UniffiExpression.expressionType in Swift, api::expression_operations::Expression::expression_type in Rust.
Top-level node kind: one of integer, rational, symbol, constant,
sum, product, power, factorial, function_call, derivative,
integral, summation, laplace_transform, inverse_laplace_transform,
fourier_transform, inverse_fourier_transform, piecewise,
ordinary_differential_equation, recurrence_equation, interval,
finite_set, set_union, set_intersection, set_complement,
image_set, condition_set.
node_count#
Raw WebAssembly: Expression method
nodeCount(): numberNumber of nodes in the expression tree — the size measure used by the simplifier; useful for comparing alternative forms.
duplicate#
Expression method
duplicate(): ExpressionAn independent handle to the same underlying expression. The recommended
JavaScript facade duplicates values before passing them through
ownership-transferring raw WASM arrays, so ordinary facade calls are
non-destructive. Callers using facade.raw directly must still duplicate a
handle they intend to retain. Python arguments are borrowed.
Equality#
equals#
Raw WebAssembly: Expression method
equals(other: Expression): booleanMathematical equality test: . A False result
means "could not prove equal", not a disproof.
Shape queries#
is_matrix#
Not exposed by the WASM / JavaScript bindings. Available as Expression.is_matrix in Python, UniffiExpression.isMatrix in Kotlin, UniffiExpression.isMatrix in Swift, api::Expression::is_matrix in Rust.
Always False on expressions and True on Matrix objects, so mixed
result streams can be discriminated.
is_equality#
Not exposed by the WASM / JavaScript bindings. Available as Expression.is_equality in Python, UniffiExpression.isEquality in Kotlin, UniffiExpression.isEquality in Swift, api::Expression::is_equality in Rust.
True for equal(a, b) relation nodes.
is_integral#
Not exposed by the WASM / JavaScript bindings. Available as Expression.is_integral in Python, UniffiExpression.isIntegral in Kotlin, UniffiExpression.isIntegral in Swift, api::Expression::is_integral in Rust.
True for unevaluated integral nodes. (Distinct from the assumption query
is_integer.)
is_union#
Not exposed by the WASM / JavaScript bindings. Available as Expression.is_union in Python, UniffiExpression.isUnion in Kotlin, UniffiExpression.isUnion in Swift, api::Expression::is_union in Rust.
is_image_set#
Not exposed by the WASM / JavaScript bindings. Available as Expression.is_image_set in Python, UniffiExpression.isImageSet in Kotlin, UniffiExpression.isImageSet in Swift, api::Expression::is_image_set in Rust.
is_finite_set#
Not exposed by the WASM / JavaScript bindings. Available as Expression.is_finite_set in Python, UniffiExpression.isFiniteSet in Kotlin, UniffiExpression.isFiniteSet in Swift, api::Expression::is_finite_set in Rust.
is_interval#
Not exposed by the WASM / JavaScript bindings. Available as Expression.is_interval in Python, UniffiExpression.isInterval in Kotlin, UniffiExpression.isInterval in Swift, api::Expression::is_interval in Rust.
Assumption queries (three-valued)#
All return True/False/None (undefined in JS): a definite verdict
only on proof from the structure and the symbol assumptions.
is_real#
Not exposed by the WASM / JavaScript bindings. Available as Expression.is_real in Python, UniffiExpression.isReal in Kotlin, UniffiExpression.isReal in Swift, api::Expression::is_real in Rust.
is_positive#
Not exposed by the WASM / JavaScript bindings. Available as Expression.is_positive in Python, UniffiExpression.isPositive in Kotlin, UniffiExpression.isPositive in Swift, api::Expression::is_positive in Rust.
is_negative#
Not exposed by the WASM / JavaScript bindings. Available as Expression.is_negative in Python, UniffiExpression.isNegative in Kotlin, UniffiExpression.isNegative in Swift, api::Expression::is_negative in Rust.
is_integer#
Not exposed by the WASM / JavaScript bindings. Available as Expression.is_integer in Python, UniffiExpression.isInteger in Kotlin, UniffiExpression.isInteger in Swift, api::Expression::is_integer in Rust.
is_rational#
Not exposed by the WASM / JavaScript bindings. Available as Expression.is_rational in Python, UniffiExpression.isRational in Kotlin, UniffiExpression.isRational in Swift, api::Expression::is_rational in Rust.
is_nonzero#
Not exposed by the WASM / JavaScript bindings. Available as Expression.is_nonzero in Python, UniffiExpression.isNonzero in Kotlin, UniffiExpression.isNonzero in Swift, api::Expression::is_nonzero in Rust.
is_nonnegative#
Expression method
isNonnegative(): boolean | nullCalling forms
Raw WebAssembly: Expression method: Expression.isNonnegative
isNonnegative(): boolean | undefinedAnswers True only on proof that the expression is greater than or equal to
zero — an even power of a provably real base, a sum or product of such, or
anything already provably positive. It never answers False: a failure to
prove non-negativity is not a proof of negativity, so the undecided verdict is
None.
is_finite#
Not exposed by the WASM / JavaScript bindings. Available as Expression.is_finite in Python, UniffiExpression.isFinite in Kotlin, UniffiExpression.isFinite in Swift, api::Expression::is_finite in Rust.
is_defined#
Not exposed by the WASM / JavaScript bindings. Available as Expression.is_defined in Python, UniffiExpression.isDefined in Kotlin, UniffiExpression.isDefined in Swift, api::Expression::is_defined in Rust.
Answers True only on proof that the expression denotes one scalar value at the
active point, and False only on proof that it denotes none — a zero
denominator, a zero logarithm argument, or a proved indeterminate extended-value
combination. Definedness is pointwise: it says nothing about continuity or
analyticity near the point, and a point on a chosen principal branch cut such as
log(-1) is defined even though the principal logarithm is discontinuous there.
The signed infinities are defined extended-real values but are not finite.
Structural accessors#
interval_lower#
Not exposed by the WASM / JavaScript bindings. Available as Expression.interval_lower in Python, UniffiExpression.intervalLower in Kotlin, UniffiExpression.intervalLower in Swift, api::Expression::interval_lower in Rust.
Lower endpoint of an interval node; raises on other shapes.
interval_upper#
Not exposed by the WASM / JavaScript bindings. Available as Expression.interval_upper in Python, UniffiExpression.intervalUpper in Kotlin, UniffiExpression.intervalUpper in Swift, api::Expression::interval_upper in Rust.
integral_integrand#
Not exposed by the WASM / JavaScript bindings. Available as Expression.integral_integrand in Python, UniffiExpression.integralIntegrand in Kotlin, UniffiExpression.integralIntegrand in Swift, api::Expression::integral_integrand in Rust.
integral_variable#
Not exposed by the WASM / JavaScript bindings. Available as Expression.integral_variable in Python, UniffiExpression.integralVariable in Kotlin, UniffiExpression.integralVariable in Swift, api::Expression::integral_variable in Rust.
integral_lower_bound#
Not exposed by the WASM / JavaScript bindings. Available as Expression.integral_lower_bound in Python, UniffiExpression.integralLowerBound in Kotlin, UniffiExpression.integralLowerBound in Swift, api::Expression::integral_lower_bound in Rust.
None for indefinite integrals.
integral_upper_bound#
Not exposed by the WASM / JavaScript bindings. Available as Expression.integral_upper_bound in Python, UniffiExpression.integralUpperBound in Kotlin, UniffiExpression.integralUpperBound in Swift, api::Expression::integral_upper_bound in Rust.
union_components#
Not exposed by the WASM / JavaScript bindings. Available as Expression.union_components in Python, UniffiExpression.unionComponents in Kotlin, UniffiExpression.unionComponents in Swift, api::Expression::union_components in Rust.
image_set_lambda_expression#
Not exposed by the WASM / JavaScript bindings. Available as Expression.image_set_lambda_expression in Python, UniffiExpression.imageSetLambdaExpression in Kotlin, UniffiExpression.imageSetLambdaExpression in Swift, api::Expression::image_set_lambda_expression in Rust.
image_set_variable#
Not exposed by the WASM / JavaScript bindings. Available as Expression.image_set_variable in Python, UniffiExpression.imageSetVariable in Kotlin, UniffiExpression.imageSetVariable in Swift, api::Expression::image_set_variable in Rust.
image_set_domain#
Not exposed by the WASM / JavaScript bindings. Available as Expression.image_set_domain in Python, UniffiExpression.imageSetDomain in Kotlin, UniffiExpression.imageSetDomain in Swift, api::Expression::image_set_domain in Rust.
to_list#
Not exposed by the WASM / JavaScript bindings. Available as Expression.to_list in Python, UniffiExpression.toList in Kotlin, UniffiExpression.toList in Swift, api::Expression::to_list in Rust.
Elements of a finite set; raises on other shapes. Python finite sets also
support len() and iteration.
length#
Element count of a finite set (Python: len(expression)).
String conversion#
to_string#
Human-readable form; Python uses str(expression) / repr(expression).
symbol_name#
Not exposed by the WASM / JavaScript bindings. Available as Expression.symbol_name in Python, UniffiExpression.symbolName in Kotlin, UniffiExpression.symbolName in Swift, api::Expression::symbol_name in Rust.
Returns the name of a symbol expression and rejects every other expression kind.
numerator_denominator#
Raw WebAssembly: Default context
numeratorDenominator(input_expression: Expression): Expression[]Calling forms
Explicit context: Context.numeratorDenominator
numeratorDenominator(value: ExpressionLike): NumeratorDenominatorRaw WebAssembly: Explicit context: Context.numeratorDenominator
numeratorDenominator(input_expression: Expression): Expression[]SymiFacade method: SymiFacade.numeratorDenominator
numeratorDenominator(value: ExpressionLike): NumeratorDenominatorExpression method: Expression.numeratorDenominator
numeratorDenominator(): NumeratorDenominatorRaw WebAssembly: Expression method: Expression.numeratorDenominator
numeratorDenominator(): Expression[]Returns the exact structural numerator and denominator without combining sums or cancelling factors. Python returns a two-tuple and the JavaScript facade returns a record.
numerator#
Raw WebAssembly: Default context
numerator(input_expression: Expression): ExpressionCalling forms
Raw WebAssembly: Explicit context: Context.numerator
numerator(input_expression: Expression): ExpressionExpression method: Expression.numerator
numerator(): ExpressionRaw WebAssembly: Expression method: Expression.numerator
numerator(): ExpressionReturns the structural numerator from numerator_denominator.
denominator#
Raw WebAssembly: Default context
denominator(input_expression: Expression): ExpressionCalling forms
Raw WebAssembly: Explicit context: Context.denominator
denominator(input_expression: Expression): ExpressionExpression method: Expression.denominator
denominator(): ExpressionRaw WebAssembly: Expression method: Expression.denominator
denominator(): ExpressionReturns the structural denominator from numerator_denominator.
Example#
Inspect and rewrite an expression through its own methods.
const x = symi.symbol("x");
const target = x.power(2).subtract(1).divide(x.add(1));
console.log(target.numerator().toString());
console.log(target.denominator().toString());
console.log(target.execute().toString());is_nonpositive#
Expression method
isNonpositive(): boolean | nullCalling forms
Raw WebAssembly: Expression method: Expression.isNonpositive
isNonpositive(): boolean | undefinedWhether the expression is known to be nonpositive. Three-valued, like the other
sign predicates on this page: None means the sign was not decided from the
assumptions in force, not that the expression is positive. Compare
is_nonnegative.
Additional API#
Expression#
Type
interface ExpressionPublic type placement for Expression.
expressionType#
Raw WebAssembly: Expression method
expressionType(): stringTop-level node kind: one of integer, rational, symbol, constant, sum, product, power, factorial, function_call, derivative, integral, summation, laplace_transform, inverse_laplace_transform, fourier_transform, inverse_fourier_transform, piecewise, ordinary_differential_equation, recurrence_equation, interval, finite_set, set_union, set_intersection, set_complement, image_set, condition_set.
freeVariables#
Raw WebAssembly: Expression method
freeVariables(): string[]Sorted names of the free symbols. Bound binders (integration variables, image-set parameters) are excluded; the constants pi/e are not symbols.
imageSetDomain#
Raw WebAssembly: Expression method
imageSetDomain(): ExpressionThe domain an image_set expression maps over.
imageSetLambdaExpression#
Raw WebAssembly: Expression method
imageSetLambdaExpression(): ExpressionThe body an image_set expression applies to its bound variable.
imageSetVariable#
Raw WebAssembly: Expression method
imageSetVariable(): stringThe name of the variable an image_set expression binds.
integralIntegrand#
Raw WebAssembly: Expression method
integralIntegrand(): ExpressionThe integrand of an unevaluated integral expression.
integralLowerBound#
Raw WebAssembly: Expression method
integralLowerBound(): Expression | undefinedNone for indefinite integrals.
integralUpperBound#
Raw WebAssembly: Expression method
integralUpperBound(): Expression | undefinedThe upper bound of an unevaluated integral, or None when it is indefinite.
integralVariable#
Raw WebAssembly: Expression method
integralVariable(): stringThe name of the variable an unevaluated integral integrates over.
intervalLower#
Raw WebAssembly: Expression method
intervalLower(): ExpressionLower endpoint of an interval node; raises on other shapes.
intervalUpper#
Raw WebAssembly: Expression method
intervalUpper(): ExpressionThe upper endpoint of an interval expression.
isAlgebraic#
Expression method
isAlgebraic(): boolean | nullWhether the expression is known to be algebraic.
Calling forms
Raw WebAssembly: Expression method: Expression.isAlgebraic
isAlgebraic(): boolean | undefinedisComplex#
Expression method
isComplex(): boolean | nullWhether the expression is known to be finite complex.
Calling forms
Raw WebAssembly: Expression method: Expression.isComplex
isComplex(): boolean | undefinedisComposite#
Expression method
isComposite(): boolean | nullWhether the expression is known to be composite.
Calling forms
Raw WebAssembly: Expression method: Expression.isComposite
isComposite(): boolean | undefinedisDefined#
Expression method
isDefined(): boolean | nullWhether the expression is known to denote one scalar value at the active point.
Calling forms
Raw WebAssembly: Expression method: Expression.isDefined
isDefined(): boolean | undefinedisEquality#
Raw WebAssembly: Expression method
isEquality(): booleanTrue for equal(a, b) relation nodes.
isEven#
Expression method
isEven(): boolean | nullWhether the expression is known to be even.
isExtendedReal#
Expression method
isExtendedReal(): boolean | nullWhether the expression is known to be extended-real.
Calling forms
Raw WebAssembly: Expression method: Expression.isExtendedReal
isExtendedReal(): boolean | undefinedisFinite#
Expression method
isFinite(): boolean | nullWhether the expression is known finite, or None when the assumptions cannot decide it.
Calling forms
Raw WebAssembly: Expression method: Expression.isFinite
isFinite(): boolean | undefinedisFiniteSet#
Raw WebAssembly: Expression method
isFiniteSet(): booleanWhether this expression is a finite_set.
isImageSet#
Raw WebAssembly: Expression method
isImageSet(): booleanWhether this expression is an image_set.
isInfinite#
Expression method
isInfinite(): boolean | nullWhether the expression is known to be infinite.
Calling forms
Raw WebAssembly: Expression method: Expression.isInfinite
isInfinite(): boolean | undefinedisInteger#
Expression method
isInteger(): boolean | nullWhether the expression is known to be an integer, or None when the assumptions cannot decide it.
Calling forms
Raw WebAssembly: Expression method: Expression.isInteger
isInteger(): boolean | undefinedisIntegral#
Raw WebAssembly: Expression method
isIntegral(): booleanTrue for unevaluated integral nodes. (Distinct from the assumption query is_integer.)
isInterval#
Raw WebAssembly: Expression method
isInterval(): booleanWhether this expression is an interval.
isIrrational#
Expression method
isIrrational(): boolean | nullWhether the expression is known to be irrational.
Calling forms
Raw WebAssembly: Expression method: Expression.isIrrational
isIrrational(): boolean | undefinedisMatrix#
Raw WebAssembly: Expression method
readonly isMatrix: booleanAlways False on expressions and True on matrix objects, so mixed result streams can be discriminated.
isNatural#
Expression method
isNatural(): boolean | nullWhether the expression is known to be natural.
Calling forms
Raw WebAssembly: Expression method: Expression.isNatural
isNatural(): boolean | undefinedisNegative#
Expression method
isNegative(): boolean | nullWhether the expression is known to be negative, or None when the assumptions cannot decide it.
Calling forms
Raw WebAssembly: Expression method: Expression.isNegative
isNegative(): boolean | undefinedisNonzero#
Expression method
isNonzero(): boolean | nullWhether the expression is known to be nonzero, or None when the assumptions cannot decide it.
Calling forms
Raw WebAssembly: Expression method: Expression.isNonzero
isNonzero(): boolean | undefinedisOdd#
Expression method
isOdd(): boolean | nullWhether the expression is known to be odd.
isPositive#
Expression method
isPositive(): boolean | nullWhether the expression is known to be positive, or None when the assumptions cannot decide it.
Calling forms
Raw WebAssembly: Expression method: Expression.isPositive
isPositive(): boolean | undefinedisPositiveInteger#
Expression method
isPositiveInteger(): boolean | nullWhether the expression is known to be a positive integer.
Calling forms
Raw WebAssembly: Expression method: Expression.isPositiveInteger
isPositiveInteger(): boolean | undefinedisRational#
Expression method
isRational(): boolean | nullWhether the expression is known to be rational, or None when the assumptions cannot decide it.
Calling forms
Raw WebAssembly: Expression method: Expression.isRational
isRational(): boolean | undefinedisReal#
Expression method
isReal(): boolean | nullWhether the expression is known to be real, or None when the assumptions cannot decide it.
isTranscendental#
Expression method
isTranscendental(): boolean | nullWhether the expression is known to be transcendental.
Calling forms
Raw WebAssembly: Expression method: Expression.isTranscendental
isTranscendental(): boolean | undefinedisUnion#
Raw WebAssembly: Expression method
isUnion(): booleanWhether this expression is a union of sets.
isZero#
Expression method
isZero(): boolean | nullWhether the expression is known to be zero.
symbolName#
Expression method
symbolName(): stringReturns the name of a symbol expression and rejects every other expression kind.
toList#
Raw WebAssembly: Expression method
toList(): Expression[]Elements of a finite set; raises on other shapes. Python finite sets also support len() and iteration.
unionComponents#
Raw WebAssembly: Expression method
unionComponents(): Expression[]The components of a set union, as a list of expressions.
NumeratorDenominator#
Type
interface NumeratorDenominatorPublic type placement for NumeratorDenominator.
NumeratorDenominator.denominator#
NumeratorDenominator property
denominator: ExpressionReturns the structural denominator from numerator_denominator.
NumeratorDenominator.numerator#
NumeratorDenominator property
numerator: ExpressionReturns the structural numerator from numerator_denominator.