Programming Exercise (HP-15C, 15C LE - and others)
|
03-26-2014, 07:01 PM
(This post was last modified: 03-26-2014 07:02 PM by Gerson W. Barbosa.)
Post: #41
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(03-26-2014 06:20 PM)churichuro Wrote: version for HP PRIME: Isn't "FOR n FROM 10000 DOWNTO 2 STEP -2 DO" a valid syntax in your UBASIC? If so, then the following would be worth trying. ¡Gracias! Code:
4 minutes and 7 seconds! (HP-71B) |
|||
03-28-2014, 03:18 AM
Post: #42
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
I implemented the two term version of this on my "HP55".
Here is the code (sorry its not in location/keycode form but you get the idea): Code:
For N=100, it took about 82sec to finish. Based on this it would take about 2.25hours for N=10000. Notice that I used double quotes around "HP55", that's because I don't own a real HP55 calculator (I only own a HP32SII, HP48SX, HP48GX, and HP50G). What to do if you don't own a classic HP? Use an emulator? -- Boring!! You build your own classic HP calculator, of course. For a learning experience (and for fun), I implemented a classic HP "core" in a Xilinx FPGA (designed in VHDL). I build this from scratch based on info I gleamed from the web (including the HP Museum). It can run ROMs for a HP35, HP45 and HP55. My "HP55" runs at two speeds:
In turbo mode, with N=10000, my "HP55" completes this task in just under 5 seconds! I think, even if its not the fastest time posted, that's a record for classic HP hardware. Brian (If anyone wants more info on the FPGA Classic HP Core I designed, let me know and I'll try to write something up for a thread in the "Not quite HP Calculators - but related" forum.) |
|||
03-28-2014, 08:28 AM
Post: #43
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others) | |||
03-28-2014, 03:48 PM
(This post was last modified: 03-28-2014 03:50 PM by Gerson W. Barbosa.)
Post: #44
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(03-28-2014 03:18 AM)bkn42 Wrote: For N=100, it took about 82sec to finish. Based on this it would take about 2.25hours for N=10000. I would ask you about the result. Never mind, here it is: Very accurate result in 2 h 16 m 53s. Not bad for a calculator in 1975! I don't have an HP-55 either, but it should take exactly the same on a physical one. I've used Eric Smith's Nonpareil High-Fidellity Calculator Simulator (I don't have a working link right now, sorry!). (03-28-2014 03:18 AM)bkn42 Wrote: What to do if you don't own a classic HP? Use an emulator? -- Boring!! You build your own classic HP calculator, of course. Quite impressive! Congratulations! (03-28-2014 03:18 AM)bkn42 Wrote: (If anyone wants more info on the FPGA Classic HP Core I designed, let me know and I'll try to write something up for a thread in the "Not quite HP Calculators - but related" forum.) Please do! Best regards, Gerson. |
|||
03-28-2014, 04:48 PM
Post: #45
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others) | |||
03-28-2014, 07:17 PM
Post: #46
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others) | |||
03-28-2014, 10:42 PM
Post: #47
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
Sorry, I forgot to mention the result from the turbo mode of my FPGA based HP55. The result was: 0.693097183
It seems people are interested in my FPGA design. So, I'll start a thread in the other forum describing its details. It might be a few days before I get something written. Brian |
|||
03-29-2014, 12:36 AM
Post: #48
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
Nobody mentioned that entering $$\sum _{ K=1 }^{ 10000 }{ \frac { { (-1 })^{ K+1 } }{ K } }$$ on the Prime with no need for any sort of coding would instantly return 0.693097183025
Is that off scope consideration for this thread? I know that the prime is blazing fast but the speed is so impressive that I wonder if the calculator is actually performing a loop? |
|||
03-29-2014, 02:21 AM
(This post was last modified: 03-29-2014 02:46 AM by Gerson W. Barbosa.)
Post: #49
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(03-29-2014 12:36 AM)Tugdual Wrote: Nobody mentioned that entering $$\sum _{ K=1 }^{ 10000 }{ \frac { { (-1 })^{ K+1 } }{ K } }$$ on the Prime with no need for any sort of coding would instantly return 0.693097183025 It does do the summation, term by term (unless acceleration techniques I am not aware of are being used - anyway 10000 terms are too few, given the Prime clock speed) . Too bad the last two digits are wrong, though. This is the CAS, I presume, but the Prime has a more exact mode, I think. This approximation is exact to 20 digits. The HP-71B evaluates it in 0.17 seconds: Code:
.69309718306 .17 For the HP-71B, that's instantly :-) Gerson. |
|||
03-29-2014, 12:02 PM
Post: #50
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(03-29-2014 12:36 AM)Tugdual Wrote: Nobody mentioned that entering $$\sum _{ K=1 }^{ 10000 }{ \frac { { (-1 })^{ K+1 } }{ K } }$$ on the Prime with no need for any sort of coding would instantly return 0.693097183025That's the solution to: Quote:(a) addition of terms from left to rightWhat about: Quote:(b) addition of terms from right to leftCompare the results and explain the difference. Can you do even better? Cheers Thomas |
|||
03-29-2014, 12:32 PM
Post: #51
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(03-29-2014 12:02 PM)Thomas Klemm Wrote:For (b) I did:(03-29-2014 12:36 AM)Tugdual Wrote: Nobody mentioned that entering $$\sum _{ K=1 }^{ 10000 }{ \frac { { (-1 })^{ K+1 } }{ K } }$$ on the Prime with no need for any sort of coding would instantly return 0.693097183025That's the solution to: $$\sum _{ K=10000 }^{ 1 }{ \frac { { (-1 })^{ K+1 } }{ K } }$$ I can't explain the difference because the result is the same |
|||
03-29-2014, 12:36 PM
(This post was last modified: 03-29-2014 12:38 PM by Tugdual.)
Post: #52
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(03-29-2014 02:21 AM)Gerson W. Barbosa Wrote: It does do the summation, term by term (unless acceleration techniques I am not aware of are being used - anyway 10000 terms are too few, given the Prime clock speed) . Too bad the last two digits are wrong, though. This is the CAS, I presume, but the Prime has a more exact mode, I think.This was in Home mode (the clue is the upper case variable name, Home accepts only upper case, CAS is on lower case). BTW when I enter this (with lower case 'k') into CAS I get the message "Error: Invalid dimension". Oh well, that is just the Prime being prime-itive... |
|||
03-29-2014, 01:29 PM
Post: #53
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(03-29-2014 12:02 PM)Thomas Klemm Wrote:(03-29-2014 12:36 AM)Tugdual Wrote: Nobody mentioned that entering $$\sum _{ K=1 }^{ 10000 }{ \frac { { (-1 })^{ K+1 } }{ K } }$$ on the Prime with no need for any sort of coding would instantly return 0.693097183025That's the solution to: You're right! I overlooked that when I suggested the Prime CAS was inexact for this one. It turns out I was inexact. Sorry! The HP 50g gives the same result for item (a): '∑(n=1,10000,(-1)^(n+1)/n)' EVAL --> 0.693097183025 For item (b), the Prime should give the same result we get on the HP 50g: '∑(n=1,10000,(-1)^n/(10001-n))' EVAL --> 0.693097183059 However this takes too long on the HP 50g: 1 minute 50 seconds. Cheers, Gerson. |
|||
03-29-2014, 05:19 PM
Post: #54
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(03-29-2014 12:32 PM)Tugdual Wrote: For (b) I did:That's interesting! Thus the order doesn't seem to be changed. Could you try the following (similar to Gerson's 2nd example on the HP-50g): $$\sum_{K=1}^{10000}{\frac{{(-1})^{K}}{10001-K}}$$ Thanks Thomas PS: When I tried this on the emulator I got: Error: Invalid input IIRC this was an issue with the original firmware which was fixed meanwhile. I didn't bother to upgrade. Is a new version of the emulator available? |
|||
03-29-2014, 05:41 PM
Post: #55
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(03-29-2014 12:36 AM)Tugdual Wrote: Nobody mentioned that entering $$\sum _{ K=1 }^{ 10000 }{ \frac { { (-1 })^{ K+1 } }{ K } }$$ on the Prime with no need for any sort of coding would instantly return 0.693097183025 For reference: The TI-36X Pro arrived at the answer of 0.693097183 in 5:45 minutes. The Casio fx-115ES Plus took just over 11 minutes to arrived at the answer of 0.6930971831. It's a good thing these models are solar powered Not bad for $20 machines. |
|||
03-29-2014, 05:59 PM
Post: #56
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(03-29-2014 05:19 PM)Thomas Klemm Wrote: That's interesting! Thus the order doesn't seem to be changed.Now I do get a different result: 0.693097183059 So looks like the Prime is always reordering (03-29-2014 05:19 PM)Thomas Klemm Wrote: PS: When I tried this on the emulator I got:I do also get an error when using CAS. You sure you were on Home? |
|||
03-29-2014, 06:23 PM
(This post was last modified: 03-29-2014 06:25 PM by Thomas Klemm.)
Post: #57
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(03-29-2014 05:59 PM)Tugdual Wrote: So looks like the Prime is always reordering Quote:You sure you were on Home?Pretty much. I didn't use CAS at all. |
|||
03-29-2014, 07:10 PM
(This post was last modified: 03-29-2014 07:14 PM by Tugdual.)
Post: #58
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(03-29-2014 06:23 PM)Thomas Klemm Wrote:Are you sure you use the latest version?(03-29-2014 05:59 PM)Tugdual Wrote: So looks like the Prime is always reordering Oh and BTW the CAS version also fails in the emulator but with a different error message: |
|||
03-29-2014, 07:17 PM
Post: #59
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others) | |||
03-29-2014, 08:07 PM
Post: #60
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others) | |||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)