-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[BUG] error when handling coefficients with fractions #2594
Comments
Thanks, would be nice to improve math.simplify('w * -2 / 5 + (-(2 * w) - 3) / 2').toString()
// actual output: "w * -2 / 5 + (-(2 * w) - 3) / 2"
// expected output: "w * -7 / 5 + -3 / 2" Anyone interested in writing additional rules for |
Hi, I would like to take a shot at this. Haven't contributed to an open source project yet so please excuse the obvious mistakes if any. The simplify function breaks ( no further simplification is done ) if the inner string is of the form n1 + ( n1 * c1 + c2) / c3. The approach would then be to simplify that to something like n1+((c1*n1)/c3+c2/c3). Is that correct ? |
Thanks Ayush. It will indeed be a solution around expanding the two terms inside the parenthesis, and/or extracting the constants out of it and then simplifying the constant terms. It will require some trial and error I think to see how things work out and if there are no unwanted side effects. |
So adding one extra rule in the form of |
Came to report a similar issue and found this one already open. A simpler example of the problem, if it helps:
|
Sorry, what's the desired output in this case? |
Steps to reproduce:
simplify('w/5-(2w+3)/2-3w/5')
tosimplify%28%27w%2F5-%282w%2B3%29%2F2-3w%2F5%27%29
using any URL encoder (I used https://www.urlencoder.io/).w * -2 / 5 + (-(2 * w) - 3) / 2
.Expected output:
$$\frac{w}{5}-\frac{2w+3}{2}-\frac{3w}{5} = -\frac75w-\frac32$$
The text was updated successfully, but these errors were encountered: