cortex-js / compute-engine

An engine for symbolic manipulation and numeric evaluation of math formulas expressed with MathJSON
https://cortexjs.io
MIT License
356 stars 42 forks source link

Cannot evaluate dfx function #169

Closed kingfisherphuoc closed 2 months ago

kingfisherphuoc commented 2 months ago

Description

The dfx expression did not work: \int_1^8\!5\,\mathrm{d}x

Steps to Reproduce

(Required) Provide steps that are specific and repeatable

  1. Add expression: \int_1^8\!5\,\mathrm{d}x to a math field
  2. Using CE to evaluate the value: const expr = expression.N()
  3. Try to get the value as below:
    const expr = expression.N();
    console.log("expr.toString()", expr.toString());
    if (expr.numericValue) {
    return `${expr.value}`;
    } else {
    return "unknown-error";
    }

Actual Behavior

(Required) What happened when you followed the steps above?

I got: Uncaught Error: Symbol cannot be defined: no scope available

Expected Behavior

(Required) What did you expect to happen instead? It may be obvious to you what should have happened, but if you don't state it explicitly it may not be obvious to others.

There should be no error and the result should be 35.

Environment

MathLive version : 0.9.6

Operating System _macOS, Android

Browser Chrome/Webview

P/s: The problem gone if I only use this one: \int_1^85

arnog commented 2 months ago

The actual expression is \int_1^8\!5\,\mathrm{d}x. Two backslashes character were missing.

kingfisherphuoc commented 2 months ago

@arnog well, even with your expression above, I still got exception: Uncaught Error: Symbol cannot be defined: no scope available (the expression was valid: expression.isValid true)