Programming Exercise (HP-15C, 15C LE - and others) - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: Programming Exercise (HP-15C, 15C LE - and others) (/thread-916.html) |
RE: Programming Exercise (HP-15C, 15C LE - and others) - Gerson W. Barbosa - 03-26-2014 07:01 PM (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) RE: Programming Exercise (HP-15C, 15C LE - and others) - bkn42 - 03-28-2014 03:18 AM 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.) RE: Programming Exercise (HP-15C, 15C LE - and others) - Didier Lachieze - 03-28-2014 08:28 AM (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. I, for one, am very interested in this HW emulator. RE: Programming Exercise (HP-15C, 15C LE - and others) - Gerson W. Barbosa - 03-28-2014 03:48 PM (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. RE: Programming Exercise (HP-15C, 15C LE - and others) - Thomas Klemm - 03-28-2014 04:48 PM (03-28-2014 03:48 PM)Gerson W. Barbosa Wrote: Please do!1+ RE: Programming Exercise (HP-15C, 15C LE - and others) - Marcel Samek - 03-28-2014 07:17 PM (03-28-2014 03:18 AM)bkn42 Wrote: I implemented the two term version of this on my "HP55". I used this code on the HP-67. 100: 47.4 seconds (.688172179) 10000: 1 hour 19 minutes 21.9 seconds (.693097183) RE: Programming Exercise (HP-15C, 15C LE - and others) - bkn42 - 03-28-2014 10:42 PM 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 RE: Programming Exercise (HP-15C, 15C LE - and others) - Tugdual - 03-29-2014 12:36 AM 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? RE: Programming Exercise (HP-15C, 15C LE - and others) - Gerson W. Barbosa - 03-29-2014 02:21 AM (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. RE: Programming Exercise (HP-15C, 15C LE - and others) - Thomas Klemm - 03-29-2014 12:02 PM (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 RE: Programming Exercise (HP-15C, 15C LE - and others) - Tugdual - 03-29-2014 12:32 PM (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 RE: Programming Exercise (HP-15C, 15C LE - and others) - Tugdual - 03-29-2014 12:36 PM (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... RE: Programming Exercise (HP-15C, 15C LE - and others) - Gerson W. Barbosa - 03-29-2014 01:29 PM (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. RE: Programming Exercise (HP-15C, 15C LE - and others) - Thomas Klemm - 03-29-2014 05:19 PM (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? RE: Programming Exercise (HP-15C, 15C LE - and others) - Steve Simpkin - 03-29-2014 05:41 PM (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. RE: Programming Exercise (HP-15C, 15C LE - and others) - Tugdual - 03-29-2014 05:59 PM (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? RE: Programming Exercise (HP-15C, 15C LE - and others) - Thomas Klemm - 03-29-2014 06:23 PM (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. RE: Programming Exercise (HP-15C, 15C LE - and others) - Tugdual - 03-29-2014 07:10 PM (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: RE: Programming Exercise (HP-15C, 15C LE - and others) - Thomas Klemm - 03-29-2014 07:17 PM (03-29-2014 07:10 PM)Tugdual Wrote: Are you sure you use the latest version? (03-29-2014 05:19 PM)Thomas Klemm Wrote: I didn't bother to upgrade. Is a new version of the emulator available? RE: Programming Exercise (HP-15C, 15C LE - and others) - Tugdual - 03-29-2014 08:07 PM (03-29-2014 07:17 PM)Thomas Klemm Wrote:Hmmm kinda depend on the version you have now(03-29-2014 07:10 PM)Tugdual Wrote: Are you sure you use the latest version?(03-29-2014 05:19 PM)Thomas Klemm Wrote: I didn't bother to upgrade. Is a new version of the emulator available? |