asc-community/AngouriMath

is there a way to stop the evaluation of the a string while using .Latexise() function

Closed this issue · 11 comments

I am trying to parse a string to Latex, while doing so any given numbers in the string are usually evaluated and turned into one long hard to read number, is there a way to stop that ?

Hi, there's no evaluation on Latexise. Can you give an example / post code?
image

Hi, sure, I will give you a simple one, "0.86 * (WV/190)^2".Latexise(); returns

image

also for some reason, hyperbolic tan is dealt with in it´s exponential form and messing up the equation badly,

image

using this code "(0.578)/sqrt(tanh((3.68*Hf)/(D)))".Latexise() gives you what what is given above

Hi, sure, I will give you a simple one, "0.86 * (WV/190)^2".Latexise(); returns

image

also for some reason, hyperbolic tan is dealt with in it´s exponential form and messing up the equation badly,

image

using this code "(0.578)/sqrt(tanh((3.68*Hf)/(D)))".Latexise() gives you what what is given above

the only thing which could lead to such case is evaluating/simplifying the expressions at some point after calling Latexise() function

Here's the result in my case for the first one:
image

also for some reason, hyperbolic tan is dealt with in it´s exponential form and messing up the equation badly

Yeah, that's fair. The reason is because we don't have a separate entity for tanh, so it's just straight substituted, like this

Let me check my code, I will be back.

Hi, "Ac * Wc".Latexise() for some reason doesn´t show the multiplication sign, as for the upper problems it turned out that I used another library, my bad

image

"((PWS) * D * (H^2) )/ 2" is below
image

is there a way to allow the parser to deal with certain characters as variables ?

the problem is => Q * Fv * (S1) is written as
image

"Ac * Wc".Latexise() for some reason doesn´t show the multiplication sign

Yeah. The idea was to mimic math notation, where we also often omit it. I agree that it's ambiguous in this case, thanks for the report.

the problem is => Q * Fv * (S1) is written as

For subscript use _, like this:
image

"Ac * Wc".Latexise() for some reason doesn´t show the multiplication sign

Yeah. The idea was to mimic math notation, where we also often omit it. I agree that it's ambiguous in this case, thanks for the report.

the problem is => Q * Fv * (S1) is written as

For subscript use _, like this: image

regarding the disappearance of the multiplication sign, is there a way to just turn it of ? or force it to always write it?

I'm afraid, no. You can make a workaround the following way:

  1. Create your own node instead of Entity.Mulf, e. g. ExplicitMul and inherit it from Entity
  2. Using method Replace you can replace it with your node:
public Entity ReplaceMul(Entity expr) => expr switch
{
    Entity.Mulf(var a, var b) => new ExplicitMul(a, b),
    var other => other
};
...
var newExpr = expr.Replace(ReplaceMul);

And for your ExplicitMul, override method Latexise to always display the multiplication sign. Here's the current implementation of Latexise for Entity.Mulf