The complex number expression to parse
OptionalreturnAST?: booleanIf true, returns an abstract syntax tree (AST) instead of a string
OptionalreturnJSON?: booleanIf true, returns an AST in JSON instead of a string
OptionalreturnLaTeX?: booleanIf true, returns LaTeX code instead of a string
OptionalroundTo?: numberOptional number of decimal places to round the result to
Optionalvalues?: Record<string, ChalkboardComplex>Optional object mapping variable names to values
// Returns -2 + 4i
const expr1 = Chalkboard.comp.parse("z^2 + 1", { values: { z: Chalkboard.comp.init(1, 2) } });
// Returns 16x^4 + 81y^4 + 96x^3y + 216x^2y^2 + 216y^3x
const expr2 = Chalkboard.comp.parse("(2x + 3y)^4");
// Returns -23.0631 + 18.6612i
const expr3 = Chalkboard.comp.parse("(1 + exp(2i))(3 + sin(4i))");
// Returns w\mathrm{exp}\left(z\right) + \mathrm{exp}\left(z\right)
const expr4 = Chalkboard.comp.parse("exp(z)(w + 1)", { returnLaTeX: true });
// Returns {"type":"add","left":{"type":"mul","left":{"type":"var","name":"w"},"right":{"type":"func","name":"exp","args":[{"type":"var","name":"z"}]}},"right":{"type":"func","name":"exp","args":[{"type":"var","name":"z"}]}}
const expr5 = Chalkboard.comp.parse("exp(z)(w + 1)", { returnJSON: true });
Parses, simplifies, and optionally evaluates a complex number expression.