The Museum of HP Calculators

HP Forum Archive 19

 HP-12C mini-challenge (e^pi)Message #1 Posted by Gerson W. Barbosa on 21 Oct 2009, 8:32 a.m. Try to write a 10-step program on the HP-12C (final GTO 00 doesn't count) that displays, and keeps displaying, the so-called Gelfond's Constant, that is, epi = 23.14069264 (the value we get on all scientific Voyagers) or 23.14069263 (better 10-digit result). Paul Dale has already two solutions based on his 9-step sequences for pi in a former thread, so the challenge will consist in finding as many 10-step sequences as possible. Besides Paul Dale's solutions below, there are at least five other 10-step solutions for 23.14069264 . Of course one single 9-step (or less) solution will supersede them all. ```8 ex 1 4 8 - 8 9 %T ex 8 ex 5 ex INTG - 8 9 %T ex ``` Gerson.

 Re: HP-12C mini-challenge (e^pi)Message #2 Posted by Valentin Albillo on 22 Oct 2009, 6:50 a.m.,in response to message #1 by Gerson W. Barbosa Hi, Gerson: Related to your HP-12C mini-challenge, there's a way to get ePi in an HP-15C without using neither ex nor Pi, in just 6 steps. As for your HP-12C challenge, the extremely simple: ``` 10691 ENTER 462 / ``` courtesy of my IDENTIFY HP-71B program is just 10 steps long and returns 23.14069264, as required. Best regards from V. Edited: 22 Oct 2009, 7:01 a.m.

 Re: HP-12C mini-challenge (e^pi)Message #3 Posted by Gerson W. Barbosa on 22 Oct 2009, 7:33 a.m.,in response to message #2 by Valentin Albillo Hi Valentin, Quote: As for your HP-12C challenge, the extremely simple: ``` 10691 ENTER 462 / ``` Yes, you have found one of them. There are at least three more variants of this one which fit in ten steps, and a very different one I came up with. Thanks for your participation! Best regards, Gerson.

 Re: HP-12C mini-challenge (e^pi)Message #4 Posted by Lyuka on 25 Oct 2009, 5:51 p.m.,in response to message #3 by Gerson W. Barbosa Hello BTW, I wrote "fractional approximation program for the HP 15C", and it returns '10691 / 462' for '23.14069263' .

 Re: HP-12C mini-challenge (e^pi)Message #5 Posted by Gerson W. Barbosa on 22 Oct 2009, 8:07 a.m.,in response to message #2 by Valentin Albillo Quote: Related to your HP-12C mini-challenge, there's a way to get ePi in an HP-15C without using neither ex nor Pi, in just 6 steps. If ex is allowed, it can be done in 5 steps: ```1 CHS ENTER Re<>Im yx ``` Best regards, Gerson. Edited: 22 Oct 2009, 8:10 a.m.

 Re: HP-12C mini-challenge (e^pi)Message #6 Posted by Gerson W. Barbosa on 25 Oct 2009, 2:40 p.m.,in response to message #5 by Gerson W. Barbosa Quote: If ex is allowed, Somehow I mistook yx for ex. So it was already there, in just 5 steps!

 Re: HP-12C mini-challenge (e^pi)Message #7 Posted by Steve Perkins on 22 Oct 2009, 6:12 p.m.,in response to message #2 by Valentin Albillo Trivially from Valentin's solution: ``` 21382 ENTER 924 / ```

 Re: HP-12C mini-challenge (e^pi)Message #8 Posted by Gerson W. Barbosa on 22 Oct 2009, 7:37 p.m.,in response to message #7 by Steve Perkins I had missed that one, but it should count, so now we have eight 10-steps solutions. If we multiply epi by 14 we get 323.969696859, which is surprisingly close to 323 32/33 (32.96969696...) or 10691/14, which divided by 14 is equivalent to Valentin's solution, 10691/462 (and your trivial solution, of course :-) This rational approximation allows for solutions like ```3 2 4 ENTER 3 3 1/x - 1 4 / ``` but it is not short enough for our purpose (but you can try one of your trivial solutions on this one ;-) Edited: 22 Oct 2009, 7:55 p.m.

 Re: HP-12C mini-challenge (e^pi)Message #9 Posted by Steve Perkins on 23 Oct 2009, 3:45 p.m.,in response to message #7 by Steve Perkins Trivially from my solution from Valentin's solution: ``` 21382 ENTER 77 / 12/ (the single function under the "i" key) ```

 Re: HP-12C mini-challenge (e^pi)Message #10 Posted by Steve Perkins on 23 Oct 2009, 3:51 p.m.,in response to message #7 by Steve Perkins And another realization: ``` 21382 12/ (the single function under the "i" key) 77 / ``` Giving the solution in 9 steps. Edited: I just realized that on the original HP-12C the "12/" function does NOT fix the resulting number on the stack (enable stack lift?) ready for the 77 above. So it doesn't work without the extra ENTER. On my HP-12C platinum it DOES enable stack lift and works as I expected it to. Interesting. So just an unsatisfying solution that works for some models. Edited: 23 Oct 2009, 3:58 p.m.

 Re: HP-12C mini-challenge (e^pi)Message #11 Posted by Gerson W. Barbosa on 23 Oct 2009, 4:31 p.m.,in response to message #10 by Steve Perkins Quote: I just realized that on the original HP-12C the "12/" function does NOT fix the resulting number on the stack (enable stack lift?) ready for the 77 above. So it doesn't work without the extra ENTER. I had noticed this too but I didn't know it would work on the 12C Platinum because I don't have one. Looks like this is an old bug that has been corrected on the 12C Platinum. Both my 12C (CN04808261) and 12C+ (CNA 83816873) have the same behavior. Anyway, your 9-step solution is a record, albeit it works only on the Platinum. The solution in your previous post was on my list, so we have now eight 10-step solutions that work on any 12C plus one 9-step solution that works only on the 12C Platinum. The list is growing... Gerson. Edited to correct a typo Edited: 23 Oct 2009, 4:47 p.m.

 Re: HP-12C mini-challenge (e^pi)Message #12 Posted by Gerson W. Barbosa on 25 Oct 2009, 1:05 p.m.,in response to message #2 by Valentin Albillo Hi Valentin, Quote: Related to your HP-12C mini-challenge, there's a way to get ePi in an HP-15C without using neither ex nor Pi, in just 6 steps. Indeed: ``` 1 Re<>Im ENTER yx 1/x x2 ``` If at least pi were allowed it would have been possible in 5 steps: ``` pi SINH LSTx COSH + ``` Regards, Gerson.

 Re: HP-12C mini-challenge (e^pi)Message #13 Posted by Karl Schneider on 22 Oct 2009, 9:52 p.m.,in response to message #1 by Gerson W. Barbosa Quote: ... Gelfond's Constant, that is, epi = 23.14069264 (the value we get on all scientific Voyagers) or 23.14069263 (better 10-digit result) Ah, but this minor flaw need not be accepted. It is possible to honestly calculate Gelfond's Constant to full 10-digit accuracy on any scientific Voyager without resorting to elaborate multiprecision methods or unorthodox techniques. It is, um, "E-Z". The problem, of course, is that pi is returned to only 10 digits, compromising the accuracy of the exponential calculation. Utilizing ```sin (pi - x) = sin x ~= x (for very small x) e^(x + y) = e^x * e^y ``` First, obtain several extra digits of pi that are correct after rounding, and incorporate them into the latter of two parts of the input argument for the exponential, which is then evaluated separately and recombined: ```FIX 9 RAD pi 1E-9 - ENTER SIN x<>y 3.1 - LASTx e^x R_down + e^x R_up (or three R_down on the HP-10C) * answer = 23.14069263 ``` Subtracting 1E-9 yields the first 10 correct digits of pi, so that the two calculated digits are the correct rounded digits of pi. This subtraction is not absolutely necessary. OK, I didn't say that it was worth doing, just that it was possible... BTW, clicking your "Gelfond's Constant" link reveals a "Gelfond-Schneider Constant". I cannot truthfully claim any credit... ;-) -- KS Edited: 23 Oct 2009, 1:56 a.m.

 Re: HP-12C mini-challenge (e^pi)Message #14 Posted by Valentin Albillo on 23 Oct 2009, 8:38 a.m.,in response to message #13 by Karl Schneider Karl posted: "BTW, clicking your "Gelfond's Constant" link reveals a "Gelfond-Schneider Constant". I cannot truthfully claim any credit ... " I fed its 12-digit value ( 2.66514414268 ) to my IDENTIFY program but it duly returned 2Sqrt(2) so no joy. Best regards from V.

 Re: HP-12C mini-challenge (e^pi) (Edited for correction)Message #15 Posted by Gerson W. Barbosa on 23 Oct 2009, 8:45 a.m.,in response to message #13 by Karl Schneider Quote: ```answer = 23.14069263 ``` That's indeed the correct 10-digit answer, but how can we be so sure? The problem doesn't lie on your method, which is absolutely corret, but on the calculator itself as there is no warranty all ten significant digits returned by transcedental functions are always correct (even though most of times they are). We can try, for instance, ```keystroke display pi 3.141592654 3 3 / 1.047197551 e^x 2.849653908 ; can we trust this final 8? 3 3 y^x 23.14069263 ; if not, how can we trust this final 3? ``` and still don't be sure of the result. However, your endeavoring to be accurate is quite appreciated. Regards, Gerson. ----------------------- Correction: I had forgotten to take into account the guard-digits. By redoing your procedure on a 12-digit calculator (to simulate the guard-digits when applied), I see we can take for granted your 10-digit answer is really exact: ```RAD pi 3.141592654 1E-9 1E-9 - 3.141592653 ENTER 3.141592653 SIN 5.9E-10 x<>y 3.141592653 3.1 3.1 - 0.041592653 LASTx 3.1 e^x 22.1979512814 ; e^3.1 22.19795128 ; rounded to 10 digits of the display R_down 0.041592653 + 0.04159265359 e^x 1.04246974594 ; e^0.04159265359 1.042469746 ; rounded to 10 digits of the display R_up (or three R_down on the HP-10C) 22.19795128 ; 23.1406926326 ; 22.19795128 * 1.042469746 23.14069263 ; correct rounded 10-digit answer ``` Sorry for the mistake! Edited: 23 Oct 2009, 8:19 p.m.

 e^pi to 10 and 12 digitsMessage #16 Posted by Karl Schneider on 24 Oct 2009, 2:48 a.m.,in response to message #15 by Gerson W. Barbosa Gerson -- Thanks for going through my calculation step-by-step, illustratively. I hadn't actually done so, but knew that the answer was correct, and believed that it was not a coincidence, because two extra digits of pi were utilized. The point of it was really the basic mathematical formulae, significant digits, and a simple application thereof. The method doesn't buy any extra accuracy for 12-digit inputs and three guard digits, because the 12-digit 'best' value of pi, 3.14159265359, is already quite close to the 15-digit 'best' value 3.14159265358979. If the exact answer were not readily available (as in the not-so-old days), it could be reasonably inferred, without absolute certainty, by interpolation from adjacent 10-digit inputs that 23.14069263 is the closest 10-digit result for e^pi: ``` pi e^pi 3.141592653 23.14069262 3.141592654 23.14069264 3.14159265359 23.1406926328 ``` -- KS Edited: 24 Oct 2009, 3:30 a.m.

 Re: HP-12C mini-challenge (e^pi)Message #17 Posted by Paul Dale on 25 Oct 2009, 5:00 p.m.,in response to message #1 by Gerson W. Barbosa Two possible nine step solutions for the 12cp: ``` 4 x^2 7 . 7 y^x 6 * LN 8 x^2 5 . 3 y^x 3 * LN ``` Both unrelated to the existing solutions. Are these related to the very different one Gerson mentioned? Replacing the x^2 with ENTER * making them ten steps and suitable for the 12c of course. - Pauli

 Re: HP-12C mini-challenge (e^pi)Message #18 Posted by Gerson W. Barbosa on 26 Oct 2009, 5:00 p.m.,in response to message #17 by Paul Dale Quote: Are these related to the very different one Gerson mentioned? You have found another different family that gives the best 10-digit answer and includes at least a couple of 9-step solutions that will work on ALL 12C versions. Your solutions can be rewritten for two more 10-step solutions: ```6 LN 16 LN 7.7 * + 3 LN 64 LN 5.3 * + ``` Regards, Gerson.

 HP-12C mini-challenge (e^pi) - Solutions Message #19 Posted by Gerson W. Barbosa on 26 Oct 2009, 7:14 a.m.,in response to message #1 by Gerson W. Barbosa Despite epi is not so appealing as pi and other more widely known mathematical constants this mini-challenge has elicited interesting and insightful responses. Thanks to all participants! Here is a compilation of all available solutions so far: 10-step solutions ```8 ex 1 4 8 - 8 9 %T ex (Paul Dale) 8 ex 5 ex INTG - 8 9 %T ex (Paul Dale) 8 7 8 LN 1 6 * ENTER LN / (Gerson W. Barbosa) 1 6 2 ENTER 6 6 1/x - 7 / 1 0 6 9 1 ENTER 4 6 2 / (Valentin Albillo) 2 1 3 8 2 ENTER 9 2 4 / (Steve Perkins) 2 1 3 8 2 ENTER 7 7 / 12/ 6 5 ENTER 4 6 2 / 2 3 + 4 ENTER * 7 . 7 yx 6 * LN (Paul Dale) 8 ENTER * 5 . 3 yx 3 * LN (Paul Dale) ``` 9-step solutions (12CP only) ```2 1 3 8 2 12/ 7 7 / (Steve Perkins) 4 x2 7 . 7 yx 6 * LN (Paul Dale) 8 x2 5 . 3 yx 3 * LN (Paul Dale) ``` Gerson. Edited: 26 Oct 2009, 11:19 a.m.

 Re: HP-12C mini-challenge (e^pi) - Solutions Message #20 Posted by Paul Dale on 26 Oct 2009, 5:15 p.m.,in response to message #19 by Gerson W. Barbosa Nice collection of solutions and a fun challenge. I'd be a little surprised if there weren't quite a few more ten step solutions to this. Finding them is the difficult part. Still, nobody found the elusive nine step solution if such exists. - Pauli

 Re: HP-12C mini-challenge (e^pi) - Solutions Message #21 Posted by Gerson W. Barbosa on 26 Oct 2009, 5:29 p.m.,in response to message #20 by Paul Dale Quote: I'd be a little surprised if there weren't quite a few more ten step solutions to this. There are at least two more of them, actually just a rewriting of your own, see my reply to your post above. Quote: Still, nobody found the elusive nine step solution if such exists. There are at least a couple of 9-step solutions that will work on the 12C as well, both based on yours. Gerson. Edited: 26 Oct 2009, 5:32 p.m.

 Re: HP-12C mini-challenge (e^pi) - Solutions Message #22 Posted by Paul Dale on 26 Oct 2009, 8:00 p.m.,in response to message #21 by Gerson W. Barbosa These two nine step solutions are an obvious continuation of my previous: ``` 2 n! 2 9 . 8 y^x 12x LN 4 INTG 1 4 . 9 y^x 12x LN ``` I think these two are nicer: ``` 2 LN 8 EXP INTG % EXP 12x LN 8 EXP INTG 2 LN % EXP 12x LN ``` - Pauli

 Re: HP-12C mini-challenge (e^pi) - Solutions Message #23 Posted by Gerson W. Barbosa on 26 Oct 2009, 9:16 p.m.,in response to message #22 by Paul Dale Quote: ``` 2 n! 2 9 . 8 y^x 12x LN 4 INTG 1 4 . 9 y^x 12x LN ``` Congratulations! Exactly what I had derived from yours, by solving LN(12*4^X)=EXP(PI) and LN(12*2^X)=EXP(PI) for X on the 33s: ```4 ENTER 1 4 . 9 yx 12* LN 2 ENTER 2 9 . 8 yx 12* LN ``` Equivalent expressions could also have been found by hand, as in `6*167.7 = 6*1677/10 = 12*1/2*xroot(10,1677) = 12*xroot(10,1677/210) = 12*xroot(10,2308/210) = 12*xroot(10,2298) = 12*229.8` but it was way easier with the SOLVER :-) LN(12*16^X)=EXP(PI) and LN(12*32^X)=EXP(PI) give two more 10-step solutions (plenty of them by now!). Quote: I think these two are nicer: ``` 2 LN 8 EXP INTG % EXP 12x LN 8 EXP INTG 2 LN % EXP 12x LN ``` I wonder how many more 9-step solutions there are! Regards, Gerson. Edited: 26 Oct 2009, 9:18 p.m.

 Re: HP-12C mini-challenge (e^pi) - Solutions Message #24 Posted by Paul Dale on 26 Oct 2009, 9:26 p.m.,in response to message #23 by Gerson W. Barbosa Quote:I wonder how many more 9-step solutions there are! Forget the 9-step solutions. Is there an eight? I suspect not but would like to be proved wrong. - Pauli

 Re: HP-12C mini-challenge (e^pi) - Solutions Message #25 Posted by Gerson W. Barbosa on 30 Oct 2009, 7:44 a.m.,in response to message #24 by Paul Dale I wish there were something as simple as ```2 1 ENTER sqrt sqrt + ``` Anyway not so bad, considering just six keystrokes for the first seven digits and the decimal point... Gerson.

 Re: HP-12C mini-challenge (e^pi)Message #26 Posted by Paul Dale on 27 Oct 2009, 6:19 a.m.,in response to message #1 by Gerson W. Barbosa Can anyone do likewise for pi^e = 22.459157718361... My 15c gives 22.45915771 for this. Correctly rounded it should be 22.45915772. So, what can people find for the 12c? Currently, I've no better solution than the obvious type in the number. However, I'm sure someone can do better than 11 operations. - Pauli

 HP-12C mini-challenge (pi^e)Message #27 Posted by Gerson W. Barbosa on 27 Oct 2009, 12:54 p.m.,in response to message #26 by Paul Dale ``` 1 5 7 sqrt . 5 5 7 9 / -> 22.45915772 ``` Gerson. Edited: 27 Oct 2009, 12:57 p.m.

 e^pi < > pi^e ? [Minor update]Message #28 Posted by Karl Schneider on 28 Oct 2009, 12:41 a.m.,in response to message #27 by Gerson W. Barbosa A year or two ago, a Forum participant offered a small "challenge" of sorts for young math students: Knowing that pi and e were both near 3 in magnitude, and pi > e, how would one go about deducing whether e^pi or pi^e had the greater value, without actually calculating them? Here's a straightforward approach I think most of us would follow: ``` e^pi ? pi^e ln (e^pi) ? ln (pi^e) pi ? e * ln (pi) e * (pi/e) ? e * ln (pi) Because to raise e to a given higher value requires a greatermultiplier than exponent, pi/e > ln (pi). Applying this from the bottom upwards, we conclude that e^pi > pi^e. ``` 12-digit answers: e^pi = 23.1406926328 pi^e = 22.4591577184 e^pi is only about 3% greater than pi^e. Similar, simpler numbers: 2^3 = 8 3^2 = 9 but 3^4 = 81 4^3 = 64 Paul Dale posted: Quote: Can anyone do likewise for pi^e = 22.459157718361... My 15c gives 22.45915771 for this. Correctly rounded it should be 22.45915772. If anyone can present a reasonably-straightforward way to obtain this actual value of pi^e to ten digits on a pre-Saturn HP, I'd like to see it, because I'm stumped... On an HP-42S with both pi and e rounded to nine decimal digits (10 significant digits), pi^e = 22.4591577145, so it appears that the HP-15C's result is the best possible, given its limitations. -- KS Edited: 1 Nov 2009, 3:48 p.m. after one or more responses were posted

 Re: e^pi < > pi^e ?Message #29 Posted by Paul Dale on 28 Oct 2009, 12:47 a.m.,in response to message #28 by Karl Schneider This little puzzle was the inspiration for my follow up challenge. I've seen it a number of times over the years and I think it is one of the gems of mathematics. - Pauli

 Re: HP-12C mini-challenge (e^pi)Message #30 Posted by Paul Dale on 2 Nov 2009, 4:08 p.m.,in response to message #26 by Paul Dale Here are two nine step solutions to the pi^e variation. Both give the correctly rounded result as required. ``` .0788 LN 25 + 25 EXP 7.88 % LN ``` Yes, they are essentially the same. The 12cp has at least three more variations on these two by utilising 5 x^2 instead of 25 and commutating the addition. - Pauli Edited: 6 Nov 2009, 7:17 a.m. after one or more responses were posted

 Re: HP-12C mini-challenge (e^pi)Message #31 Posted by Gerson W. Barbosa on 6 Nov 2009, 7:03 a.m.,in response to message #30 by Paul Dale Quote: ``` .0788 LN 25 + ``` Nice one! My 10-step solution was found with help a tiny 12c program. I started with n=500 and manually checked sqrt(n)/pi^e for interesting answers as n decreased by one unit. The Turbo Pascal code below tries to automate the process. I tried other functions but didn't find anything better. I quit! Gerson. ---------------- ```Program Ep; var n: integer; d: array[1..9] of byte; m: array[0..9] of byte; g,i,j,r: byte; k,f,x: real; begin ReadLn(k,r); n:=1500; repeat x:=sqrt(n)/k; f:=frac(x); m[0]:=0; for i:=1 to 9 do begin f:=10*f; d[i]:=trunc(f); f:=frac(f); m[i]:=0 end; for i:=0 to 9 do for j:=1 to 9 do if d[j]=i then m[i]:=m[i]+1; g:=m[0]; for i:=1 to 9 do if m[i]>g then g:=m[i]; if g>r-1 then WriteLn(n:4,' ',x:12:10); n:=n-1 until n=1 end. 22.459157718 5 1418 1.6766586370 1413 1.6736999994 1346 1.6335373355 1236 1.5653655450 1181 1.5301411115 1051 1.4434704347 1009 1.4143344442 804 1.2625092229 754 1.2226220048 628 1.1157999996 625 1.1131316817 610 1.0996929796 596 1.0870003024 211 0.6467668658 189 0.6121212228 157 0.5578999998 -> pie ~ sqrt(157)/0.5579 ```

Go back to the main exhibit hall