Skip to content
Symi Docs
WASM / JavaScript

Signatures in the WASM / JavaScript view are TypeScript. Where the JavaScript facade wraps an operation its form is listed first; the other calling forms are the raw wasm-bindgen exports.

On this page

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(): boolean

Reports 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): Expression
Calling forms

Raw WebAssembly: Expression method: Expression.add

add(other: Expression): Expression

subtract#

Expression method

subtract(other: ExpressionLike): Expression
Calling forms

Raw WebAssembly: Expression method: Expression.subtract

subtract(other: Expression): Expression

multiply#

Expression method

multiply(other: ExpressionLike): Expression
Calling forms

Raw WebAssembly: Expression method: Expression.multiply

multiply(other: Expression): Expression

divide#

Expression method

divide(other: ExpressionLike): Expression
Calling forms

Raw WebAssembly: Expression method: Expression.divide

divide(other: Expression): Expression

power#

Expression method

power(exponent: ExpressionLike): Expression
Calling forms

Raw WebAssembly: Expression method: Expression.power

power(exponent: Expression): Expression

negate#

Expression method

negate(): Expression
Calling forms

Raw WebAssembly: Expression method: Expression.negate

negate(): Expression

Substitution and structure#

substitute#

Raw WebAssembly: Expression method

substitute(variable: string, value: Expression): Expression

Replace 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,
): Expression
Calling forms

Raw WebAssembly: Explicit context: Context.rewriteInTermsOf

rewriteInTermsOf(
    target: Expression,
    source: Expression,
    replacement: Expression,
): Expression

Raw WebAssembly: Expression method: Expression.rewriteInTermsOf

rewriteInTermsOf(
    source: Expression,
    replacement: Expression,
): Expression

Rewrite 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(): number

Number of nodes in the expression tree — the size measure used by the simplifier; useful for comparing alternative forms.

duplicate#

Expression method

duplicate(): Expression
Calling forms

Raw WebAssembly: Expression method: Expression.duplicate

duplicate(): Expression

An 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): boolean

Mathematical equality test: simplify⁡(self⁡−other⁡)=0\operatorname{simplify}(\operatorname{self} - \operatorname{other}) = 0. 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 | null
Calling forms

Raw WebAssembly: Expression method: Expression.isNonnegative

isNonnegative(): boolean | undefined

Answers 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): NumeratorDenominator

Raw WebAssembly: Explicit context: Context.numeratorDenominator

numeratorDenominator(input_expression: Expression): Expression[]

SymiFacade method: SymiFacade.numeratorDenominator

numeratorDenominator(value: ExpressionLike): NumeratorDenominator

Expression method: Expression.numeratorDenominator

numeratorDenominator(): NumeratorDenominator

Raw 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): Expression
Calling forms

Raw WebAssembly: Explicit context: Context.numerator

numerator(input_expression: Expression): Expression

Expression method: Expression.numerator

numerator(): Expression

Raw WebAssembly: Expression method: Expression.numerator

numerator(): Expression

Returns the structural numerator from numerator_denominator.

denominator#

Raw WebAssembly: Default context

denominator(input_expression: Expression): Expression
Calling forms

Raw WebAssembly: Explicit context: Context.denominator

denominator(input_expression: Expression): Expression

Expression method: Expression.denominator

denominator(): Expression

Raw WebAssembly: Expression method: Expression.denominator

denominator(): Expression

Returns the structural denominator from numerator_denominator.

Example#

Inspect and rewrite an expression through its own methods.

JavaScript
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 | null
Calling forms

Raw WebAssembly: Expression method: Expression.isNonpositive

isNonpositive(): boolean | undefined

Whether 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 Expression

Public type placement for Expression.

expressionType#

Raw WebAssembly: Expression method

expressionType(): string

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.

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(): Expression

The domain an image_set expression maps over.

imageSetLambdaExpression#

Raw WebAssembly: Expression method

imageSetLambdaExpression(): Expression

The body an image_set expression applies to its bound variable.

imageSetVariable#

Raw WebAssembly: Expression method

imageSetVariable(): string

The name of the variable an image_set expression binds.

integralIntegrand#

Raw WebAssembly: Expression method

integralIntegrand(): Expression

The integrand of an unevaluated integral expression.

integralLowerBound#

Raw WebAssembly: Expression method

integralLowerBound(): Expression | undefined

None for indefinite integrals.

integralUpperBound#

Raw WebAssembly: Expression method

integralUpperBound(): Expression | undefined

The upper bound of an unevaluated integral, or None when it is indefinite.

integralVariable#

Raw WebAssembly: Expression method

integralVariable(): string

The name of the variable an unevaluated integral integrates over.

intervalLower#

Raw WebAssembly: Expression method

intervalLower(): Expression

Lower endpoint of an interval node; raises on other shapes.

intervalUpper#

Raw WebAssembly: Expression method

intervalUpper(): Expression

The upper endpoint of an interval expression.

isAlgebraic#

Expression method

isAlgebraic(): boolean | null

Whether the expression is known to be algebraic.

Calling forms

Raw WebAssembly: Expression method: Expression.isAlgebraic

isAlgebraic(): boolean | undefined

isComplex#

Expression method

isComplex(): boolean | null

Whether the expression is known to be finite complex.

Calling forms

Raw WebAssembly: Expression method: Expression.isComplex

isComplex(): boolean | undefined

isComposite#

Expression method

isComposite(): boolean | null

Whether the expression is known to be composite.

Calling forms

Raw WebAssembly: Expression method: Expression.isComposite

isComposite(): boolean | undefined

isDefined#

Expression method

isDefined(): boolean | null

Whether the expression is known to denote one scalar value at the active point.

Calling forms

Raw WebAssembly: Expression method: Expression.isDefined

isDefined(): boolean | undefined

isEquality#

Raw WebAssembly: Expression method

isEquality(): boolean

True for equal(a, b) relation nodes.

isEven#

Expression method

isEven(): boolean | null

Whether the expression is known to be even.

Calling forms

Raw WebAssembly: Expression method: Expression.isEven

isEven(): boolean | undefined

isExtendedReal#

Expression method

isExtendedReal(): boolean | null

Whether the expression is known to be extended-real.

Calling forms

Raw WebAssembly: Expression method: Expression.isExtendedReal

isExtendedReal(): boolean | undefined

isFinite#

Expression method

isFinite(): boolean | null

Whether the expression is known finite, or None when the assumptions cannot decide it.

Calling forms

Raw WebAssembly: Expression method: Expression.isFinite

isFinite(): boolean | undefined

isFiniteSet#

Raw WebAssembly: Expression method

isFiniteSet(): boolean

Whether this expression is a finite_set.

isImageSet#

Raw WebAssembly: Expression method

isImageSet(): boolean

Whether this expression is an image_set.

isInfinite#

Expression method

isInfinite(): boolean | null

Whether the expression is known to be infinite.

Calling forms

Raw WebAssembly: Expression method: Expression.isInfinite

isInfinite(): boolean | undefined

isInteger#

Expression method

isInteger(): boolean | null

Whether 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 | undefined

isIntegral#

Raw WebAssembly: Expression method

isIntegral(): boolean

True for unevaluated integral nodes. (Distinct from the assumption query is_integer.)

isInterval#

Raw WebAssembly: Expression method

isInterval(): boolean

Whether this expression is an interval.

isIrrational#

Expression method

isIrrational(): boolean | null

Whether the expression is known to be irrational.

Calling forms

Raw WebAssembly: Expression method: Expression.isIrrational

isIrrational(): boolean | undefined

isMatrix#

Raw WebAssembly: Expression method

readonly isMatrix: boolean

Always False on expressions and True on matrix objects, so mixed result streams can be discriminated.

isNatural#

Expression method

isNatural(): boolean | null

Whether the expression is known to be natural.

Calling forms

Raw WebAssembly: Expression method: Expression.isNatural

isNatural(): boolean | undefined

isNegative#

Expression method

isNegative(): boolean | null

Whether 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 | undefined

isNonzero#

Expression method

isNonzero(): boolean | null

Whether 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 | undefined

isOdd#

Expression method

isOdd(): boolean | null

Whether the expression is known to be odd.

Calling forms

Raw WebAssembly: Expression method: Expression.isOdd

isOdd(): boolean | undefined

isPositive#

Expression method

isPositive(): boolean | null

Whether 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 | undefined

isPositiveInteger#

Expression method

isPositiveInteger(): boolean | null

Whether the expression is known to be a positive integer.

Calling forms

Raw WebAssembly: Expression method: Expression.isPositiveInteger

isPositiveInteger(): boolean | undefined

isRational#

Expression method

isRational(): boolean | null

Whether 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 | undefined

isReal#

Expression method

isReal(): boolean | null

Whether the expression is known to be real, or None when the assumptions cannot decide it.

Calling forms

Raw WebAssembly: Expression method: Expression.isReal

isReal(): boolean | undefined

isTranscendental#

Expression method

isTranscendental(): boolean | null

Whether the expression is known to be transcendental.

Calling forms

Raw WebAssembly: Expression method: Expression.isTranscendental

isTranscendental(): boolean | undefined

isUnion#

Raw WebAssembly: Expression method

isUnion(): boolean

Whether this expression is a union of sets.

isZero#

Expression method

isZero(): boolean | null

Whether the expression is known to be zero.

Calling forms

Raw WebAssembly: Expression method: Expression.isZero

isZero(): boolean | undefined

symbolName#

Expression method

symbolName(): string

Returns the name of a symbol expression and rejects every other expression kind.

Calling forms

Raw WebAssembly: Expression method: Expression.symbolName

symbolName(): string

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 NumeratorDenominator

Public type placement for NumeratorDenominator.

NumeratorDenominator.denominator#

NumeratorDenominator property

denominator: Expression

Returns the structural denominator from numerator_denominator.

NumeratorDenominator.numerator#

NumeratorDenominator property

numerator: Expression

Returns the structural numerator from numerator_denominator.

Symi documentation · WASM / JavaScript