Algebrite
Algebrite copied to clipboard
Is it possible to increase Algebrite precision?
Is there an option in Algebrite to increase calculation precision?
Algebrite.eval(5+0.0000001).toString()
returns 5.0 instead of "5.000001" and I was wondering if there is a way to increase the precision for stuff like this.
I am using Algebrite mainly for .expand function and take a look at this case for example. I know the expansion on this example does not do anything meaningful but the issue is there none the less.
Algebrite.expand("(x)^(2)-(y)^(2)-0.000001").toString()
correctly returns "-0.000001+x^2.0-y^2.0"
but
Algebrite.expand("(x)^(2)-(y)^(2)-0.0000001").toString()
truncates the constant and returns "-0.0+x^2.0-y^2.0"
Not good...
There's a PR here for increasing the precision, but it's hardcoded and fairly limited in its scope. I haven't tested it myself since I need something broader in my own use case. (My own solution is to replace all decimals with algebraic variables, then use my own logic to evaluate them to required precision after algebrite's performed its algebraic simplifications. It's pretty ugly to have to do this.)