numbas / Numbas

A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
http://www.numbas.org.uk
Apache License 2.0
203 stars 117 forks source link

Is -1/-2 a valid fraction? #766

Closed christianp closed 2 years ago

christianp commented 3 years ago

A student wrote a fraction with minus signs on top and bottom, expecting it to be valid. They didn't think to try writing it without any minus signs.

Should we accept this sort of thing? I suppose if we did, it would have to count as not reduced.

ugoertz commented 3 years ago

In my opinion -1/-2 is clearly a valid fraction.

Whether it is reduced or not is maybe a more subtle question. I find it hard to find a trustworthy source for this kind of question; anyway it is likely that different definitions are used. The Wikipedia page says: "If the numerator and the denominator do not share any factor greater than 1, then the fraction is said to be irreducible, in lowest terms, or in simplest terms." An equivalent definition of being in simplest terms would be saying that the gcd of numerator and denominator is 1. According to this definition, the fraction -1/-2 is actually reduced.

On the other hand, it also seems reasonable to say that "simplest terms" means that in addition to the above condition the denominator has to be positive. This has the advantage that every rational number can be represented as a fraction in simplest terms in a unique way. (Taking this point of view should mean that the fraction 1/-2 is not reduced either - maybe this helps with deciding what is the best approach for NUMBAS?)

Best regards, Ulrich

jhoobergs commented 2 years ago

-1 and -2 have to common factor -1 so reduction is possible. -1/-2 is, however, clearly a valid fraction as said above.

webbdays commented 2 years ago

Here -1/-2 can be treated as valid mathematical expression. But when we talk about fractions, I think it should be simplified to 1/2. (1/q)*(p) => 1 part when p is divided into q equal parts. Same thing for -1/2 but -(minus) is taged to before 1/2 to say its a negative number/fraction.

So in this way, -1/-2 can be treated as a valid mathematical expression but has no meaning when we talk of fractions. It should be simplified first and then talk about fractions.

christianp commented 2 years ago

I've changed Numbas.util.parseFraction so it accepts a negative sign on the denominator.

I haven't added anything to say that negative signs affect whether the fraction is reduced, so -1/-2 is considered as reduced.