New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rationalize() throws exception for some input with decimals #1146
Comments
Hm, that's odd. The error you get with decimals is: math.rationalize('1/(0.1x+1)+1').toString())
// ArgumentsError: Wrong number of arguments in
// function Operator / invalid (undefined provided, undefined expected) @paulobuchsbaum do you have an idea where this can originate? |
After further investigation,
and some modification seems to solve this problem. To make
work, I needed to modify rationalize() algorithm |
When you run |
When I run
the failed test also fails in v5.0.0 and seems to have nothing to do with my change. |
Thanks for diving into this @maruta! I hope to look into this soon unless @paulobuchsbaum beats me ;) |
I've implemented a fix based on the work of @maruta (thanks again!), see 0d93fff @paulobuchsbaum and @maruta can you please review this commit? I'm not very familiar/confident with this part of the code base, so a pair of extra eyes would be helpful. |
I've released the fix based on @maruta 's work in |
I was traveling without reading my emails, but I'm back now. I think that the first change from @maruta The new condtion needs to be made with For accepting negative exponents it's only necessary only add 3 lines based on 3.19 version (my last version). It's not important but it's redundant using
The second change (related to the simplify rules) is in maruta/mathjs@b0d077f It solves its problem but adds new ones to the code, concerning tougher expressions (that was extracted from tests because was slow), because changes the rules applications procedures. The right and simpler approach is put an option in I also have added in my sets of rules 2 new rules to handle with I've tested in my local machine and the below expressions work smoothly. For testing in my local
@josdejong, can I make a new pull request? What branch? |
@josdejong @paulobuchsbaum |
Thanks for your input @paulobuchsbaum . I don't fully understand all your points but if you can turn it into a PR it would be great!
To the |
rationalize() seems to fail for some input with decimals.
So far, I tested
math.rationalize('1/(0.1x+1)+1').toString()
-> throws exception
math.rationalize('1/(1.0x+1)+1').toString()
-> "(x + 2) / (x + 1)" OK
math.rationalize('1/(0.1x+1)').toString()
-> "10 / (x + 10)" OK
with version 5.0.0.
Thanks!
The text was updated successfully, but these errors were encountered: