Re: New HP-15C mini-challenge ! Message #15 Posted by hugh steers on 15 Dec 2005, 10:18 a.m., in response to message #14 by PeterP
hi peter,
my original idea is based on a plan for generating the solutions by repeated multiplies. the sum of two squares is closed under multiplication;
(a^2+b^2)(c^2+d^2) = (ac – bd)^2 + (ad + bc)^2 ie another sum of two squares.
so it occurred to me that, given any starting a & b, let N = a^2 + b^2 then we must have N^2 = (a^2+b^2)(a^2+b^2) and it must also be the sum of two squares by the above formula and you can keep going to generate any N^m as required in terms of two squares.
i also noticed that the above is the same way complex numbers multiply.
(a+ib)(c+id) = (ac-bd) + i(ad + bc)
except that i was getting negative real parts. i wanted positive ones. so i changed the sign each time and carried on multiplying. it was you that made me realise i didn’t need to do this and should keep the negative cases – in which case there was no need for a loop to multiply, just use y^x. the other shocker is that the complex number treatment can also be done in polar coordinates. in (r,theta)^n = (r^n,n*theta). which means the 15c complex mode is not strictly required.
and then i had a very cheeky idea. my original plan of negating the real part of a complex number in polar terms means (r,theta) -> (r, pi – theta). so therefore,
(1 times) (r, theta)
(2 times) (r^2, 2*theta) -> (r^2, pi – 2*theta)
(3 times) (r^3, pi – 2*theta + theta) = (r^3, pi – theta) -> (r^3, theta)
so the theta remains the same for odd powers! so we can get away with (r,theta)^n = (r^n,theta) when n is odd, but only for the purposes of retaining two squares – not in general.
However, my cheeky idea was too cheeky because even powers went wrong. Eamonn has applied the fixup for them. However, just doubling theta would also fix it. but i cant see a trick for that.
my complex number (re)attempt came out as;
LBL A, RD, I, ENT, R^, Y^X, R/S R<>I, R/S, RD, ABS, X^2, RTN
which, when i compare it to Eamonn’s original, is really the same! so that’s not a new answer. i was hoping to somehow squeeze it down a bit more by not using the complex number mode and using instead a R->P trick.
|