On Thu, Aug 30, 2018 at 4:30 PM, Jonathan Goble <jcgob...@gmail.com> wrote: > On Thu, Aug 30, 2018, 2:08 AM Greg Ewing <greg.ew...@canterbury.ac.nz> > 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? >
For positive numbers, I believe you're correct. For negative numbers, no. >>> (-2)**(2/3) (-0.7937005259840993+1.3747296369986026j) >>> _**(3/2) (-1.9999999999999993+2.4492935982947054e-16j) >>> ((-2)**2)**(1/3) 1.5874010519681994 >>> _**(3/2) 1.9999999999999998 Rounding error aside, raising -2 to 2/3 power and then raising the result to 3/2 power gives back -2, as it should. Doing it in two steps loses the negation, and then (again, within rounding error) the end result is positive two. ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/