Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
rationalize() throws exception for some input with decimals #1146
rationalize() seems to fail for some input with decimals.
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.
work, I needed to modify rationalize() algorithm
When I run
the failed test also fails in v5.0.0 and seems to have nothing to do with my change.
I was traveling without reading my emails, but I'm back now.
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?
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!