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

Trigonometric and complex rewrites

Trigonometric, logarithmic, exponential, and complex rewrites are separated from general simplification because their identities depend on domains and branch behavior.

expand_complex#

Raw WebAssembly: Default context

expandComplex(input_expression: Expression): Expression
Calling forms

Raw WebAssembly: Explicit context: Context.expandComplex

expandComplex(input_expression: Expression): Expression

Raw WebAssembly: Expression method: Expression.expandComplex

expandComplex(): Expression

Decompose an expression exactly as real_part(expression) + i*imaginary_part(expression). Products, integer powers, and exp, sin, cos, sinh, and cosh are expanded through their Cartesian identities. Symbol assumptions determine which atoms are real. Unknown atoms and branch-sensitive operations such as logarithms and non-integer powers remain represented by symbolic real- and imaginary-part calls. The directed operation also expands a supported modulus under real assumptions: abs(x + i*y) becomes sqrt(x^2 + y^2), and exact integer powers under the modulus preserve their original poles while expanding the Cartesian norm. Oversized or unsupported modulus arguments remain unchanged or wrapper-bearing.

real_part#

Raw WebAssembly: Default context

realPart(input_expression: Expression): Expression
Calling forms

Explicit context: Context.realPart

realPart(value: ExpressionLike): Expression

Raw WebAssembly: Explicit context: Context.realPart

realPart(input_expression: Expression): Expression

SymiFacade method: SymiFacade.realPart

realPart(value: ExpressionLike): Expression

Expression method: Expression.realPart

realPart(): Expression

Raw WebAssembly: Expression method: Expression.realPart

realPart(): Expression

Return the exact real component of an expression. For example, if y is declared real, real_part(exp(i*y)) is cos(y). An atom whose reality is unknown returns a symbolic real_part(atom) call. The returned expression is always known to be real.

imaginary_part#

Raw WebAssembly: Default context

imaginaryPart(input_expression: Expression): Expression
Calling forms

Explicit context: Context.imaginaryPart

imaginaryPart(value: ExpressionLike): Expression

Raw WebAssembly: Explicit context: Context.imaginaryPart

imaginaryPart(input_expression: Expression): Expression

SymiFacade method: SymiFacade.imaginaryPart

imaginaryPart(value: ExpressionLike): Expression

Expression method: Expression.imaginaryPart

imaginaryPart(): Expression

Raw WebAssembly: Expression method: Expression.imaginaryPart

imaginaryPart(): Expression

Return the exact imaginary component of an expression. For example, if y is declared real, imaginary_part(exp(i*y)) is sin(y). An atom whose reality is unknown returns a symbolic imaginary_part(atom) call. The returned expression is always known to be real.

combine_powers#

Raw WebAssembly: Default context

combinePowers(input_expression: Expression): Expression
Calling forms

Raw WebAssembly: Explicit context: Context.combinePowers

combinePowers(input_expression: Expression): Expression

Raw WebAssembly: Expression method: Expression.combinePowers

combinePowers(): Expression

Combine same-exponent powers into a single power of the merged base (x^a * y^a -> (x*y)^a) at every product node where the rewrite is provably valid. This identity is false across the branch cut of the complex logarithm — at x = y = -1 and a = 1/2 the left side is i*i = -1 while the right side is sqrt(1) = 1 — so it fires only when the exponent is provably an integer or when every combined base is provably positive. Positivity of the merged base is not enough: (-2)^x * (-3)^x is left alone, because at x = 1/2 combining it to 6^x would flip the sign of the result. Positive numeric-literal bases need no assumptions at all, so 2^x * 3^x becomes 6^x and (1/2)^x * 3^x becomes (3/2)^x. With n declared an integer, x^n * y^n becomes (x*y)^n; the exponent gate recurses structurally, so a compound exponent like 2*n gates the same way. There is no force mode: a site whose gate is not provable is left unchanged, and an expression with no provable site is returned as-is.

expand_power_base#

Raw WebAssembly: Default context

expandPowerBase(input_expression: Expression): Expression
Calling forms

Raw WebAssembly: Explicit context: Context.expandPowerBase

expandPowerBase(input_expression: Expression): Expression

Raw WebAssembly: Expression method: Expression.expandPowerBase

expandPowerBase(): Expression

Split a power whose base is structurally a product into a product of powers ((x*y)^a -> x^a * y^a) at every power node whose exponent is provably an integer — the only unconditionally valid gate for this direction, since the split introduces x^a and y^a individually and each needs its own base off the cut. With n declared an integer, (x*y)^n becomes x^n * y^n. Kahan's example (x*y)^(1/2) over unconstrained x, y is left unchanged, as is any other unprovable site; there is no force mode. A base that is not structurally a product is never decomposed, so 6^x is not split into 2^x * 3^x.

denest_powers#

Raw WebAssembly: Default context

denestPowers(input_expression: Expression): Expression
Calling forms

Raw WebAssembly: Explicit context: Context.denestPowers

denestPowers(input_expression: Expression): Expression

Raw WebAssembly: Expression method: Expression.denestPowers

denestPowers(): Expression

Flatten a power of a power into a single power ((x^a)^b -> x^(a*b)) at every power node whose outer exponent is provably an integer, which is valid on the principal branch because an integer power never routes through log. With n declared an integer, (x^a)^n becomes x^(a*n). A fractional outer exponent is left unchanged — ((-1)^2)^(1/2) is 1 while (-1)^(2*(1/2)) is -1 — and there is no force mode. A base that is not structurally a power is untouched.

simplify_trigonometric#

Raw WebAssembly: Default context

simplifyTrigonometric(input_expression: Expression): Expression
Calling forms

Raw WebAssembly: Explicit context: Context.simplifyTrigonometric

simplifyTrigonometric(input_expression: Expression): Expression

Raw WebAssembly: Expression method: Expression.simplifyTrigonometric

simplifyTrigonometric(): Expression

Fu-style trigonometric simplification toward fewer/cheaper trig calls.

expand_trigonometric#

Raw WebAssembly: Default context

expandTrigonometric(input_expression: Expression): Expression
Calling forms

Raw WebAssembly: Explicit context: Context.expandTrigonometric

expandTrigonometric(input_expression: Expression): Expression

Raw WebAssembly: Expression method: Expression.expandTrigonometric

expandTrigonometric(): Expression

Expand trig/hyperbolic functions of sums and positive integer literal multiple angles. The directed operation may increase expression size; unsupported, symbolic, noninteger, or over-budget multipliers remain unchanged. A successful expansion is structurally idempotent, and recursively admitted sums are expanded in the same pass.

combine_trigonometric#

Raw WebAssembly: Default context

combineTrigonometric(input_expression: Expression): Expression
Calling forms

Raw WebAssembly: Explicit context: Context.combineTrigonometric

combineTrigonometric(input_expression: Expression): Expression

Raw WebAssembly: Expression method: Expression.combineTrigonometric

combineTrigonometric(): Expression

Inverse direction of expand_trigonometric: product-to-sum and angle-recombination rules.

combine_logarithm#

Raw WebAssembly: Default context

combineLogarithm(input_expression: Expression): Expression
Calling forms

Raw WebAssembly: Explicit context: Context.combineLogarithm

combineLogarithm(input_expression: Expression): Expression

Raw WebAssembly: Expression method: Expression.combineLogarithm

combineLogarithm(): Expression

log⁡a+log⁡b→log⁡(ab)\log a + \log b \rightarrow \log(a b) and nlog⁡a→log⁡(an)n\log a \rightarrow \log(a^n) when the transformation preserves the expression's domain.

expand_logarithm#

Raw WebAssembly: Default context

expandLogarithm(input_expression: Expression): Expression
Calling forms

Raw WebAssembly: Explicit context: Context.expandLogarithm

expandLogarithm(input_expression: Expression): Expression

Raw WebAssembly: Expression method: Expression.expandLogarithm

expandLogarithm(): Expression

log⁡(ab)→log⁡a+log⁡b\log(a b) \rightarrow \log a + \log b and log⁡(an)→nlog⁡a\log(a^n) \rightarrow n\log a, applied only where the operands are provably positive. Operands of unknown sign pass through unchanged.

rewrite_as_exponential#

Raw WebAssembly: Default context

rewriteAsExponential(input_expression: Expression): Expression
Calling forms

Raw WebAssembly: Explicit context: Context.rewriteAsExponential

rewriteAsExponential(input_expression: Expression): Expression

Raw WebAssembly: Expression method: Expression.rewriteAsExponential

rewriteAsExponential(): Expression

Euler-form rewriter: replace every trigonometric/hyperbolic call with the equivalent complex-exponential expression (bottom-up).

rewrite_as_trigonometric#

Raw WebAssembly: Default context

rewriteAsTrigonometric(input_expression: Expression): Expression
Calling forms

Raw WebAssembly: Explicit context: Context.rewriteAsTrigonometric

rewriteAsTrigonometric(input_expression: Expression): Expression

Raw WebAssembly: Expression method: Expression.rewriteAsTrigonometric

rewriteAsTrigonometric(): Expression

Inverse of rewrite_as_exponential. Recognition is shape-strict: canonical Euler forms collapse back to trig/hyperbolic calls, anything else passes through unchanged, so the round trip is the identity.

rewrite_trigonometric_basis#

Raw WebAssembly: Default context

rewriteTrigonometricBasis(
    input_expression: Expression,
    basis: string,
): Expression
Calling forms

Raw WebAssembly: Explicit context: Context.rewriteTrigonometricBasis

rewriteTrigonometricBasis(
    input_expression: Expression,
    basis: string,
): Expression

Raw WebAssembly: Expression method: Expression.rewriteTrigonometricBasis

rewriteTrigonometricBasis(basis: string): Expression

Rewrite trigonometric and hyperbolic calls toward one of five named bases: sine_cosine, tangent, exponential, trigonometric, or hyperbolic. The sine/cosine basis maps tan(x) to sin(x)/cos(x) and reciprocal calls to reciprocal powers; the tangent basis recognizes existing exact quotients such as sin(x)/cos(x) but leaves a bare sin(x) unchanged; the exponential basis maps sin(x) to its Euler form; the trigonometric basis recognizes those canonical Euler forms; and the hyperbolic basis maps explicit imaginary arguments such as sin(i*x) to i*sinh(x). Only identities with the same singularities on the whole complex domain are offered. In particular, the half-angle rewrite of a bare sine into tangent is excluded because it introduces undefined points. An unknown basis name is an error, and nodes without a valid rewrite are returned unchanged.

Example#

Directed rewrites between trigonometric, exponential, and complex forms.

JavaScript
const x = symi.symbol("x", { real: true });
const value = symi.exp(symi.imaginaryUnit.multiply(x));

console.log(symi.realPart(value).toString());
console.log(symi.imaginaryPart(value).toString());

Symi documentation · WASM / JavaScript