A simple 11c/15c minichallenge (phi)  Printable Version + HP Forums (https://archived.hpcalc.org/museumforum) + Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum1.html) + Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum2.html) + Thread: A simple 11c/15c minichallenge (phi) (/thread154768.html) 
A simple 11c/15c minichallenge (phi)  Gerson W. Barbosa  08202009 The goal is to obtain the golden ratio phi=1.618033989 using the least number of programming steps. There are at least two fourstep solutions (LBL and RTN don't count).
Gerson.
Re: A simple 11c/15c minichallenge (phi)  Alain Mellan  08202009 We can get a good approximation with:
4 Re: A simple 11c/15c minichallenge (phi)  Vladan Dugaric  08202009 A solution with 4 steps excluding LBL that requires manual input before starting program:
LBL A To run:
1 Eventually, the value converges to phi. This program implements the continued fraction formula: phi = 1/(1 + 1/(1 + 1/(...))) Or, an even shorter solution (3 steps):
LBL A implementing the formula phi = sqrt(1 + sqrt(1 + ...)) Again, run by pressing fA fA fA ...; this will converge with anything in X that won't cause SQRT to return an error, therefore 1 or anything greater will do. Or, even simpler (but 5 steps):
LBL A because phi = 2 cos 36 degrees. Or
1 because phi = 0.5 + diagonal of rectangle with sides (1/2, 1), but this requires 7 steps. Vladan
Edited: 20 Aug 2009, 3:25 p.m.
Re: A simple 11c/15c minichallenge (phi)  Chuck  08202009 You beat me to it Vladan. I had: Lbl Aand press R/S after running a few seconds. As you mentioned, as long as the stack starts with x>1 it will converge to phi.
CHUCK Edited: 20 Aug 2009, 3:29 p.m.
Re: A simple 11c/15c minichallenge (phi)  Jeff O.  08202009 Since: 1
is no shorter than: 1 I propose the following, which works with all starting values:
LABEL A press fA, let run for a while, then press R/S. If not converged, or if stopped with 0.6180339898 in the display, press R/S twice in rapid succession.
Re: A simple 11c/15c minichallenge (phi)  Gerson W. Barbosa  08202009 Quote: This is interesting but 5 sqrt 1 + 2 / would be one step shorter. The other solutions are also interesting but the one we are looking for is noniterative. Tip: this one (and its variation) will work on the 11c and the 15c, but will not work on any other Voyager. An older related minichallenge by Paul Dale: http://www.hpmuseum.org/cgisys/cgiwrap/hpmuseum/archv018.cgi?read=145811 Regards,
Gerson.
Re: A simple 11c/15c minichallenge (phi)  Vladan Dugaric  08202009 Something with factorial function perhaps?
HP11C and HP15C factorial is actually gamma(n+1) while 12C factorial is just factorial and does not accept decimal values. 16C does not have factorial and I don't know if 10C factorial is gamma or just factorial.
Re: A simple 11c/15c minichallenge (phi)  Gerson W. Barbosa  08202009
Quote: Answer in the Museum's Calculator Comparison Table. The solution I've found doesn't involve Gamma.
Gerson.
Re: A simple 11c/15c minichallenge (phi)  Gerson W. Barbosa  08202009 Approximations are welcome. The following is better but requires five steps:
2 Regards, Gerson.
Re: A simple 11c/15c minichallenge (phi)  Paul Dale  08202009 I can find three command sequences of length four that produce the required answer. Two are basically the same. All are exactly six key presses.
 Pauli
Re: A simple 11c/15c minichallenge (phi)  Gerson W. Barbosa  08202009 Looks like you found them (and an extra one)! Mine, which are basically the same, are fourstep long and requires exactly six key presses as well. Regards,
Gerson.
Re: A simple 11c/15c minichallenge (phi)  Gerson W. Barbosa  08202009 Quoting myself:
I think your program meets the requirement, even though that was not what I had in mind. Regards,
Gerson.
Re: A simple 11c/15c minichallenge (phi) SPOILER  Paul Dale  08202009 Okay, here us the unique one then:
6 Four commands & six keystrokes. It assumes the calculator is in DEG mode so it isn't as good as the other solutions. I won't spoil the other two :)
Re: A simple 11c/15c minichallenge (phi)  Jeff O.  08202009 I did not think for a second that that is what you had in mind. I'm sure there is a better way.
Re: A simple 11c/15c minichallenge (phi)  Valentin Albillo  08212009 Not wanting to spoil the 4step solutions either, I'll just offer this remarkable HP15Cspecific solution which works in any angular mode:
.5
Best regards from V.
Re: A simple 11c/15c minichallenge (phi)  Gerson W. Barbosa  08212009 Hello Valentin, Thanks for participating. This is based on formula (26) in http://mathworld.wolfram.com/GoldenRatio.html. I wonder why its hyperbolic counterpart, which only lacks the imaginary constant, is not there. Well, it appears now I have spoiled it all :) Best regards, Gerson.
Re: A simple 11c/15c minichallenge (phi)  Kiyoshi Akima  08212009 Do multidigit number entries count as only one step?
If so, then 1.25 Re: A simple 11c/15c minichallenge (phi)  Gerson W. Barbosa  08212009 Actually, .5 is part of one of the solutions and that alone takes up two steps on the 11c/15c. Regards,
Gerson.
Re: A simple 11c/15c minichallenge (phi)  Jeff O.  08212009 So is the anwswer: .5 or:
2 Either sequence takes me six keystrokes.
...
Re: A simple 11c/15c minichallenge (phi)  Kiyoshi Akima  08212009 Here's a twostep program that may or may not produce the desired result, depending on how lucky you get :)
RAND You may have better luck replacing the second step with e^x.
The threestep program RANDshould produce the desired result, if iterated enough times.
Please do not consider these as serious attempts at the minichallenge.
Re: A simple 11c/15c minichallenge (phi)  Gerson W. Barbosa  08212009 Yes, you've found 'em!. Interesting isn't it? http://de.wikipedia.org/wiki/Sinus_Hyperbolicus_und_Kosinus_Hyperbolicus http://pl.wikipedia.org/wiki/Funkcje_hiperboliczne (and now I know what the Polish currency, the zloty, comes from :) The equality is easy to prove:
phi=(sqrt(5)+1)/2
Gerson.
Re: A simple 11c/15c minichallenge (phi)  Gerson W. Barbosa  08212009 :) You only have to find the right seed. See message #9 in the link below: http://www.hpmuseum.org/cgisys/cgiwrap/hpmuseum/archv017.cgi?read=112157 Strange as it might seem I considered this yesterday. I thought of trying to find a seed that would generate i/phi. But I realized it would take up more than 2 steps, if it existed... Gerson.
Edited: 21 Aug 2009, 1:51 p.m.
Re: A simple 11c/15c minichallenge (phi)  Jeff O.  08212009 Yes, quite interesting. Thanks for sharing! I certainly did not find the above references. I looked at equation 26 in the reference of your previous post:
sin(i ln(phi)) = 0.5 i Then I found a calculator that can do arcsin with a complex argument (my 42s) and took arcsin(0.5i), which is 0+ i0.48121182506. I guess that told me that ln(phi) is equal to 0.48121182506. You had mentioned hyperbolics, so I wondered if arcsinh(0.5i) might go somewhere, which it did not. Then tried arcsinh(0.5) and found it equals 0.48121182506, previously found to be ln(phi), so I was done. So basically, using the clues you gave, I just fiddled around until I got the right answer. .
Edited: 21 Aug 2009, 4:02 p.m.
Re: A simple 11c/15c minichallenge (phi)  Gerson W. Barbosa  08212009 Until yesterday I hadn't looked up any reference either. I was trying to simplify some constants so that they took up less steps on the 11C. For instance, I had found 4 LN HYP SIN was equivalent to 1.875, which was a gain (3 steps instead of 5). For other constants I would do the backward sequence: k HYP^{1} SIN e^{x}. I don't remember for what reason, since there's no way to get .5 with less than two steps, I did .5 HYP^{1} SIN e^{x}. I recognized the number on the display as phi... The following is somewhat interesting:
It appears the continued fraction form for 1/n+sqrt(1+(1/n)^2), which is equivalent to e^sinh^{1}(1/n), where n is an integer greater than 1, is always [1; n1, 1, 1, n1, 1, 1, n1, 1, 1, ...]. When n=2, the continued fraction form for the expression will be [1; 1, 1, 1, 1, 1, ...], that is, phi.
Re: A simple 11c/15c minichallenge (phi)  Paul Dale  08222009 Quote: This doesn't work if there is a value in the complex X register :)
Re: A simple 11c/15c minichallenge (phi)  Paul Dale  08222009 My alternate proof of the arcsinh version.
Start with the formula for arcsinh: arcsinh(x) = ln(x + sqrt(x^2+1)) Taking EXP of this gives us:
e^arcsinh(x) = x + sqrt(x^2+1) Not let x = 1/2 and substitute into the above:
1/2 + sqrt(1/4 + 1)
36 2 >RECT in DEG mode The conversion from polar to rectangular coordinates:
 STACK IN  STACK OUT We don't care about the output in the Y register. So consider the X register output when theta is 36 degrees and r is 2:
X = r . COS(theta) Now, a quick look into some trigonometric identities / trigonometric tables or Wolfram alpha :) gives us this interesting result:
COS(36) = (1 + sqrt(5)) / 4 Finally, substitute this into the above:
X = 2 . COS(36)
Re: A simple 11c/15c minichallenge (phi)  Gerson W. Barbosa  08222009 Quote: This had occurred to me too, but in my tests it always worked. In complex mode, when only the real part is entered (.5) it is assumed the imaginary part is 0 and it will replace whatever value is there. Do you have an example?
Gerson.
Re: A simple 11c/15c minichallenge (phi)  Gerson W. Barbosa  08222009
Quote: And 2COS(36) gives
(1+sqrt(5))/2 but no explicit reference to phi... On the other hand, 1.6180339887498948482 gives
Phi+1 e^ArcSinh(1/2) gives a lot of interesting results though.
Gerson.
Re: A simple 11c/15c minichallenge (phi)  Paul Dale  08222009 Yeah, it is a bit contrived though:
22 Looks like the 15c's complex mode outsmarted me again :(  Pauli
Edited: 22 Aug 2009, 6:30 p.m.
