[Python-ideas] Fix some special cases in Fractions?

Jonathan Fine jfine2358 at gmail.com
Sat Sep 1 14:35:06 EDT 2018


Greg Ewing and Jonathan Goble wrote

>> Also, Fraction(1) for the second case would be flat-out wrong.

> How? Raising something to the 2/3 power means squaring it and then taking
> the cube root of it. -1 squared is 1, and the cube root of 1 is 1. Or am I
> having a 2:30am brain fart?

Let's see. What about computing the Fraction(2, 4) power by first
squaring and then taking the fourth root. Let's start with (-16).
Square to get +256. And then the fourth root is +4. I've just followed
process Jonathan G suggested, without noticing that Fraction(2, 4) is
equal to Fraction(1, 2).

But Fraction(1, 2) is the square root. And -16 requires complex
numbers for its square root. The problem, I think, may not be doing
something sensible in any particular case. Rather, it could be doing
something sensible and coherent in all cases. A bit like trying to fit
a carpet that is cut to the wrong size for the room.

-- 
Jonathan


More information about the Python-ideas mailing list