Elements

Class ExprElement

Maths Expression

constructor (): ExprElement

Accessor .functions

Returns a list of all functions called by the expression.

Accessor .simplified : ExprElement

Returns the simplest mathematically equivalent expression.

Accessor .unknowns

Returns a list of all variables used in the expression (excluding defined constants).

Accessor .variables

Returns a list of all variables used in the expression (including defined constants).

Method .collapse (): ExprElement

Collapses all terms into functions.

Method .evaluate (_vars: VarMap, _privateNested: boolean): number

Evaluates an expression using a given map of variables and functions.

Name Type Default Description
_vars VarMap  
_privateNested boolean    

Method .interval (vars: VarMap, _privateNested: boolean): Interval

Name Type Default Description
vars VarMap  
_privateNested boolean    

Method .recursiveSubstitute (vars: ExprMap): ExprElement

Recursively substitutes a new expression for a variable. NOTE: This function does not test for cyclical dependencies, which could lead to an infinite loop. You have to manually validate expressions first!

Name Type Default Description
vars ExprMap    

Method .substitute (_vars: ExprMap): ExprElement

Substitutes a new expression for a variable.

Name Type Default Description
_vars ExprMap  

Method .toMathML (_custom: MathMLMap): string

Converts the expression to a MathML string.

Name Type Default Description
_custom MathMLMap  

Method .toString (): string

Converts the expression to a plain text string.

Method .toVoice (_custom: MathMLMap): string

Converts the expression to a MathML string.

Name Type Default Description
_custom MathMLMap  

Class ExprIdentifier

Extends ExprElement

readonly Property .i : string

Method .evaluate (vars: VarMap, privateNested: boolean): number

Name Type Default Description
vars VarMap  
privateNested boolean    

Method .interval (vars: VarMap, privateNested: boolean): Interval

Name Type Default Description
vars VarMap  
privateNested boolean    

Method .substitute (vars: ExprMap): ExprElement

Name Type Default Description
vars ExprMap  

Method .toMathML (): string

Method .toString (): string

Method .toVoice (): string

Class ExprNumber

Extends ExprElement

readonly Property .n : number

Method .evaluate (): number

Method .toMathML (): string

Method .toString (): string

Method .toVoice (): string

Class ExprOperator

Extends ExprElement

readonly Property .o : string

Method .toMathML (): string

Method .toString (): string

Method .toVoice (): string

Class ExprSpace

Extends ExprElement

Method .toMathML (): string

Method .toString (): string

Class ExprString

Extends ExprElement

readonly Property .s : string

Method .evaluate (vars: VarMap, privateNested: boolean): number

Name Type Default Description
vars VarMap  
privateNested boolean    

Method .toMathML (): string

Method .toString (): string

Method .toVoice (): string

Interface MathMLArgument

Property .toString

Property .val : ExprElement

Type alias CustomFunction

Type alias ExprMap : Record<string, ExprElement>

Type alias MathMLMap : Record<string, (args: Array<MathMLArgument>): string>

Type alias VarMap : Record<string, number|string|Interval|ExprElement|CustomFunction>


Copyright © 2024 Mathigon.org