Interface IComputeEngineInternal

interface IComputeEngine {
    _BIGNUM_HALF: Decimal;
    _BIGNUM_NAN: Decimal;
    _BIGNUM_NEGATIVE_ONE: Decimal;
    _BIGNUM_ONE: Decimal;
    _BIGNUM_PI: Decimal;
    _BIGNUM_TWO: Decimal;
    _BIGNUM_ZERO: Decimal;
    Anything: BoxedDomain;
    bignum: ((a: bigint | Value) => Decimal);
    Booleans: BoxedDomain;
    complex: ((a: number | Complex, b?: number) => Complex);
    ComplexInfinity: BoxedExpression;
    context: null | RuntimeScope;
    costFunction: ((expr: BoxedExpression) => number);
    deadline?: number;
    E: BoxedExpression;
    False: BoxedExpression;
    Half: BoxedExpression;
    I: BoxedExpression;
    iterationLimit: number;
    latexDictionary: readonly LatexDictionaryEntry[];
    NaN: BoxedExpression;
    NegativeInfinity: BoxedExpression;
    NegativeOne: BoxedExpression;
    Nothing: BoxedExpression;
    Numbers: BoxedDomain;
    numericMode: NumericMode;
    One: BoxedExpression;
    Pi: BoxedExpression;
    PositiveInfinity: BoxedExpression;
    recursionLimit: number;
    stats: ComputeEngineStats;
    strict: boolean;
    Strings: BoxedDomain;
    timeLimit: number;
    tolerance: number;
    True: BoxedExpression;
    Void: BoxedDomain;
    Zero: BoxedExpression;
    get assumptions(): ExpressionMapInterface<boolean>;
    jsonSerializationOptions: Readonly<JsonSerializationOptions>;
    latexOptions: NumberFormattingOptions & ParseLatexOptions & SerializeLatexOptions;
    precision: number;
    _fn(head: string | BoxedExpression, ops: BoxedExpression[], metadata?: Metadata): BoxedExpression;
    _register(expr: BoxedExpression): void;
    _unregister(expr: BoxedExpression): void;
    add(ops: BoxedExpression[], metadata?: Metadata): BoxedExpression;
    array(elements: ArrayValue[] | ArrayValue[][], metadata?: Metadata): BoxedExpression;
    ask(pattern: SemiBoxedExpression): BoxedSubstitution[];
    assign(ids: {
        [id: string]: AssignValue;
    }): IComputeEngine;
    assign(id: string, value: AssignValue): IComputeEngine;
    assign(arg1: string | {
        [id: string]: AssignValue;
    }, arg2?: AssignValue): IComputeEngine;
    assume(predicate: SemiBoxedExpression): AssumeResult;
    box(expr: SemiBoxedExpression | [num: number, denom: number], options?: {
        canonical?: boolean | CanonicalForm | CanonicalForm[];
    }): BoxedExpression;
    cache<T>(name: string, build: (() => T), purge?: ((T: any) => undefined | T)): T;
    canonical(xs: SemiBoxedExpression[]): BoxedExpression[];
    checkContinueExecution(): void;
    chop(n: number): number;
    chop(n: Decimal): 0 | Decimal;
    chop(n: Complex): 0 | Complex;
    chop(n: number | Decimal | Complex): number | Decimal | Complex;
    declare(identifiers: {
        [id: string]:
            | BoxedDomain
            | DomainExpression
            | SymbolDefinition
            | FunctionDefinition;
    }): IComputeEngine;
    declare(id: string, def:
        | SymbolDefinition
        | FunctionDefinition
        | BoxedDomain
        | DomainExpression<SemiBoxedExpression>): IComputeEngine;
    declare(arg1: string | {
        [id: string]:
            | BoxedDomain
            | DomainExpression
            | SymbolDefinition
            | FunctionDefinition;
    }, arg2?:
        | SymbolDefinition
        | FunctionDefinition
        | BoxedDomain
        | DomainExpression<SemiBoxedExpression>): IComputeEngine;
    defineFunction(name: string, def: FunctionDefinition): BoxedFunctionDefinition;
    defineSymbol(name: string, def: SymbolDefinition): BoxedSymbolDefinition;
    div(num: BoxedExpression, denom: BoxedExpression, metadata?: Metadata): BoxedExpression;
    domain(domain: BoxedDomain | DomainExpression<SemiBoxedExpression>, metadata?: Metadata): BoxedDomain;
    domainError(expectedDomain: BoxedDomain | DomainLiteral, actualDomain: undefined | BoxedDomain, where?: SemiBoxedExpression): BoxedExpression;
    error(message: string | [string, ...SemiBoxedExpression[]], where?: SemiBoxedExpression): BoxedExpression;
    fn(head: SemiBoxedExpression, ops: SemiBoxedExpression[], options?: {
        canonical: boolean;
    }): BoxedExpression;
    forget(symbol?: string | string[]): void;
    hold(expr: SemiBoxedExpression): BoxedExpression;
    inv(expr: BoxedExpression, metadata?: Metadata): BoxedExpression;
    isBignum(a: unknown): a is Decimal;
    isComplex(a: unknown): a is Complex;
    lookupFunction(head: string | BoxedExpression, scope?: null | RuntimeScope): undefined | BoxedFunctionDefinition;
    lookupSymbol(name: string, wikidata?: string, scope?: RuntimeScope): undefined | BoxedSymbolDefinition;
    mul(ops: BoxedExpression[], metadata?: Metadata): BoxedExpression;
    neg(expr: BoxedExpression, metadata?: Metadata): BoxedExpression;
    number(value:
        | string
        | number
        | bigint
        | Decimal
        | Complex
        | MathJsonNumber
        | Rational, options?: {
        canonical?: boolean;
        metadata?: Metadata;
    }): BoxedExpression;
    pair(first: BoxedExpression, second: BoxedExpression, metadata?: Metadata): BoxedExpression;
    parse(s: string, options?: {
        canonical?: boolean | CanonicalForm | CanonicalForm[];
    }): BoxedExpression;
    parse(s: null, options?: {
        canonical?: boolean | CanonicalForm | CanonicalForm[];
    }): null;
    parse(s: null | string, options?: {
        canonical?: boolean | CanonicalForm | CanonicalForm[];
    }): null | BoxedExpression;
    pattern(expr: SemiBoxedExpression): Pattern;
    popScope(): IComputeEngine;
    pow(base: BoxedExpression, exponent: number | BoxedExpression | Rational, metadata?: Metadata): BoxedExpression;
    pushScope(scope?: Partial<Scope>): IComputeEngine;
    reset(): void;
    resetContext(): void;
    rules(rules: Rule[]): BoxedRuleSet;
    serialize(expr: SemiBoxedExpression, options?: {
        canonical?: boolean;
    }): string;
    shouldContinueExecution(): boolean;
    sqrt(base: BoxedExpression, metadata?: Metadata): BoxedExpression;
    string(s: string, metadata?: Metadata): BoxedExpression;
    swapScope(scope: null | RuntimeScope): null | RuntimeScope;
    symbol(sym: string, options?: {
        canonical?: boolean;
        metadata?: Metadata;
    }): BoxedExpression;
    tuple(elements: number[], metadata?: Metadata): BoxedExpression;
    tuple(elements: BoxedExpression[], metadata?: Metadata): BoxedExpression;
    verify(query: SemiBoxedExpression): boolean;
}

Implemented by

Properties

_BIGNUM_HALF: Decimal
_BIGNUM_NAN: Decimal
_BIGNUM_NEGATIVE_ONE: Decimal
_BIGNUM_ONE: Decimal
_BIGNUM_PI: Decimal
_BIGNUM_TWO: Decimal
_BIGNUM_ZERO: Decimal
Anything: BoxedDomain
bignum: ((a: bigint | Value) => Decimal)
Booleans: BoxedDomain
complex: ((a: number | Complex, b?: number) => Complex)
ComplexInfinity: BoxedExpression
context: null | RuntimeScope

The current scope

costFunction: ((expr: BoxedExpression) => number)
deadline?: number

Absolute time beyond which evaluation should not proceed

iterationLimit: number
latexDictionary: readonly LatexDictionaryEntry[]
NegativeInfinity: BoxedExpression
NegativeOne: BoxedExpression
Numbers: BoxedDomain
numericMode: NumericMode

The numeric evaluation mode:

Mode
"auto" Use bignum or complex numbers.
"machine" IEEE 754-2008, 64-bit floating point numbers: 52-bit mantissa, about 15 digits of precision
"bignum" Arbitrary precision floating point numbers, as provided by the "decimal.js" library
"complex" Complex number represented by two machine numbers, a real and an imaginary part, as provided by the "complex.js" library
PositiveInfinity: BoxedExpression
recursionLimit: number
strict: boolean
Strings: BoxedDomain
timeLimit: number
tolerance: number

Accessors

  • get assumptions(): ExpressionMapInterface<boolean>
  • Returns ExpressionMapInterface<boolean>

  • get jsonSerializationOptions(): Readonly<JsonSerializationOptions>
  • Returns Readonly<JsonSerializationOptions>

  • set jsonSerializationOptions(val): void
  • Returns void

  • get precision(): number
  • Returns number

  • set precision(p): void
  • Parameters

    • p: number | "machine"

    Returns void

Methods

  • Internal

    This is a primitive to create a boxed function. It doesn't perform any checks or normalization on its arguments.

    In general, consider using ce.fn() or ce.box() instead.

    The result is canonical, but the caller has to ensure that all the conditions are met (i.e. ops properly normalized and sorted, all ops canonical, etc..) so that the result is actually canonical.

    Parameters

    Returns BoxedExpression

  • Internal

    Parameters

    Returns void

  • Internal

    Parameters

    Returns void

  • Parameters

    Returns IComputeEngine

  • Parameters

    Returns IComputeEngine

  • Parameters

    Returns IComputeEngine

  • Parameters

    Returns AssumeResult

  • Internal

    Type Parameters

    • T

    Parameters

    • name: string
    • build: (() => T)
        • (): T
        • Returns T

    • Optionalpurge: ((T: any) => undefined | T)
        • (T): undefined | T
        • Parameters

          • T: any

          Returns undefined | T

    Returns T

  • Internal

    Returns void

  • Parameters

    • n: number

    Returns number

  • Parameters

    Returns 0 | Decimal

  • Parameters

    Returns 0 | Complex

  • Parameters

    Returns number | Decimal | Complex

  • Create a boxed function expression.

    Parameters

    Returns BoxedExpression

  • Parameters

    • Optionalsymbol: string | string[]

    Returns void

  • Parameters

    • a: unknown

    Returns a is Decimal

  • Parameters

    • a: unknown

    Returns a is Complex

  • Parameters

    • name: string
    • Optionalwikidata: string
    • Optionalscope: RuntimeScope

    Returns undefined | BoxedSymbolDefinition

  • Parameters

    • value:
          | string
          | number
          | bigint
          | Decimal
          | Complex
          | MathJsonNumber
          | Rational
    • Optionaloptions: {
          canonical?: boolean;
          metadata?: Metadata;
      }
      • Optionalcanonical?: boolean
      • Optionalmetadata?: Metadata

    Returns BoxedExpression

  • Parameters

    Returns BoxedExpression

  • Parameters

    Returns null

  • Parameters

    Returns null | BoxedExpression

  • Parameters

    Returns Pattern

  • Returns IComputeEngine

  • Parameters

    Returns IComputeEngine

  • Internal

    Returns void

  • Returns void

  • Parameters

    Returns BoxedRuleSet

  • Parameters

    • expr: SemiBoxedExpression
    • Optionaloptions: {
          canonical?: boolean;
      }
      • Optionalcanonical?: boolean

    Returns string

  • Internal

    Returns boolean

  • Parameters

    Returns BoxedExpression

  • Parameters

    Returns null | RuntimeScope

  • Parameters

    • sym: string
    • Optionaloptions: {
          canonical?: boolean;
          metadata?: Metadata;
      }
      • Optionalcanonical?: boolean
      • Optionalmetadata?: Metadata

    Returns BoxedExpression

  • Parameters

    • elements: number[]
    • Optionalmetadata: Metadata

    Returns BoxedExpression

  • Parameters

    Returns BoxedExpression

  • Parameters

    Returns boolean