Skip to content
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

math.Fraction.REDUCE doesn't work from mathjs 10.0.1 #50

Open
chrisbansart opened this issue Apr 16, 2022 · 3 comments
Open

math.Fraction.REDUCE doesn't work from mathjs 10.0.1 #50

chrisbansart opened this issue Apr 16, 2022 · 3 comments

Comments

@chrisbansart
Copy link

Hi,
First of all, thanks for the fantastic work on fractions.
I think I've figured out a bug with the flag math.Fraction.REDUCE allowing to reduce or not fractions automaticly.
With mathjs 10.0.0 the code :

math.Fraction.REDUCE = false;
var f = math.Fraction(3, 6);
console.log(f); // gives {s: 1, n: 3, d: 6, …}

From mathjs 10.0.1 the code :

math.Fraction.REDUCE = false;
var f = math.Fraction(3, 6);
console.log(f); // gives {s: 1, n: 1, d: 2, …}

Thus, it seems that from mathjs 10.0.1 the REDUCE flag has no more effect.
Thanks for your help.
Chris

@chrisbansart
Copy link
Author

Added comment : It seems that you have remove in 4.2.0 the Fraction['REDUCE'] tests.

Therefore, my workaround is to come back to mathjs 10.0.0 and install manually fraction.js version 4.1.1
npm install --save [email protected] and it works again.

@infusion
Copy link
Collaborator

infusion commented Apr 17, 2022

Yes, I removed this as it introduced overflow problems quickly and I did not like the implementation. It was added due to a bug report back then, but after running an operation on a fraction (like adding, multiplying, ...), the result can be something not expected, due to the way the operations are implemented internally. And from my perspective, and probably the standard definition, a fraction only is the ratio of numerator and denominator and thus makes much more sense to keep it in a reduced form. I searched for it in mathjs to not introduce a bug, but didn't know that people try to use it outside, like you did.
Can you elaborate, what you're trying to do and why you need a not reduced fraction?

@chrisbansart
Copy link
Author

Hello, actually I've figured out the use of the flag math.Fraction.REDUCE in an old message in this repo. Regarding my need, it's still a core feature that I implemented in the core of my project two years ago. I've been using it for educational purposes to offer learners the opportunity to work with non-reduced fractions as well as reduced fractions. For instance, I can generate non-reduced Fractions and ask learners to find their irreducible forms. Concretely I set Fraction.REDUCE globally to false to control manually the reduction of fractions. Depending on my needs, I can reduce them with the gcd operator or not. Without ability to disable automatic reduction, I cannot anymore manipulate unreduced fractions and I'm coerced to only use reduced fractions. Thus, It is a real issue for pedagogical purpose. Hope we could find a workaround...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants