Skip to content

Dealing with Infinity in parse #1842

@skgadi

Description

@skgadi

The math.parse feature is very helpful in converting a math expression or a matrix into TeX.
I have one suggestion and one doubt regarding this feature.

Scenario: I want to perform some math operation and display the output in TeX.

let a = math.matrix([1,2,3,4]);
let b = math.divide(a,0);
let c = b.toString();
let d = math.parse(c);
let texOut = d.toTex();

Suggestion:
The output is "\begin{bmatrix}Infinity\\Infinity\\Infinity\\Infinity\\\end{bmatrix}". However replacing Infinity with \infty is more appropriate.

Doubt:
Also, I am not sure if I am correctly using the last step. Because: math variable b is converted to string and then math.parse is applied. Is there any command to obtain TeX directly from b instead of converting it into a string and then back into a math.js object?

PS: In the math.js example here.

  1. If we place Infinity in the Expression, we get:
    image
  2. If we place Inf in the Expression, we get:
    image

So, I think math.evaluate and math.parse part their ways here in understanding the input string.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions