The Museum of HP Calculators

HP Forum Archive 12

[ Return to Index | Top of Index ]

HP12C Platinum with Viktor Toth's trig functions?
Message #1 Posted by Tony David Potter on 12 May 2003, 12:28 a.m.

Has anyone with access to a new Platinum and an old 12C tried to run Viktor Toth's trig function program (http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=225) to see how the times compare? I assume Viktor did his calculations on an original HP 12C, and I'm curious how the times compare to the newer 12C's (one battery job) and the 12C Platinums.

Given the discussions about the program execution speed problems with the inate programs, I'm curious.

Thanks ahead of time. Tony David Potter

      
HP12C Platinum with Viktor Toth's trig functions - Gene?
Message #2 Posted by Vieira, Luiz C. (Brazil) on 12 May 2003, 1:14 a.m.,
in response to message #1 by Tony David Potter

Hi;

I think the only one that (we know about) has an HP12C platinum in hands is Gene. Unless otherwise stated...

A few days ago I wrote a small routine to compute permutations and combinations without simplifying terms, just plain expression and existing fatorial. It is a single sequence, no jumps or subroutine calls, uses only stack register and, for a given pair a and b, it returns Ca,b and Pa,b in X and Y registers at once. It was witten after an inspiring e-mail from Michel Beauliou (thenks, Michel).

I loaded it in an HP38C, an HP38E and an HP34C. The winner was HP38E, second place HP38C and as third place, the HP34C. I wonder about step numbers and LBL/GTO/SBR structure and the many extra checks a resourcefull O.S. must perform that are not prformed by others with less power.

As Viktor Toth's trigs use (in a thoughtfull way) loops to compute and accumulate the terms of the series for sine, we we will probably face an expected slow-down effect. Also, it's necessary to add a '0' to each [GTO], I guess, but step numbers will be maintained if the program is still in the first steps. Have you imagined that? Original Viktor Toth's uses almost 80 steps, right? In the HP12C it's almost all program memory and "consumes" 7 (or eight) registers. In the 12C Platinum it uses about 1/5 of the available maemory and all registers remain intact, what means you can load trigs and still compute cash-flow with 20 entries...

Just my US$ 0.01.

Luiz C. Vieira - Brazil

            
I'll try it today
Message #3 Posted by Gene on 12 May 2003, 7:24 a.m.,
in response to message #2 by Vieira, Luiz C. (Brazil)

Let everyone know.

                  
Thanks in advance (n/t)
Message #4 Posted by Tony David Potter on 12 May 2003, 8:50 a.m.,
in response to message #3 by Gene

(n/t)

                        
12c Platinum speed results with Viktor's Trig Program and another test
Message #5 Posted by Gene on 12 May 2003, 10:50 a.m.,
in response to message #4 by Tony David Potter

Hi all. Have run a few trig tests.

Cosine Tests
X         Original 12c speed      12c Platinum speed
1.77         11 seconds              5 seconds
3.14         15 seconds              8 seconds

arc cosine test x Original 12c speed 12c platinum speed cos(pi/4) 37 seconds 24 seconds

(Note...the cosine of pi/4 is the input, so it should return pi/4 and does).

Bottom line: Run times are cut between 35% and 55%. Depends greatly upon loop vs. function calling. If you have a program that calls square roots, powers, logs, etc. very often, then you won't get a lot of speed benefit. For example:

Test loop takes log and power 10 times and stops:

LN
E^X
LN
E^X
LN
E^X
LN
E^X
LN
E^X
LN
E^X
LN
E^X
LN
E^X
LN
E^X
LN
E^X
Goto 00

Original 12c - 9 seconds 12c platinum - 8 seconds

Real pain with my 12c platinum since it turns OFF whenever it encounters a R/S or GTO 000 in a program. Nice feature, huh? (Surely they fixed this in the marketed version).
                              
Re: 12c Platinum speed results with Viktor's Trig Program and another test
Message #6 Posted by John Smith on 12 May 2003, 11:24 a.m.,
in response to message #5 by Gene

Thanks for the interesting results, Gene.

BTW, did you also test the other 12C trigs program, as you posted you would a few days ago ? I'd like to know.

All the best.

                                    
Don't have a copy of the other one
Message #7 Posted by Gene on 12 May 2003, 11:44 a.m.,
in response to message #6 by John Smith

I used to have a copy, but it disappeared on the drive.

I'll be glad to test it.

                                          
[LONG] Re: Don't have a copy of the other one
Message #8 Posted by John Smith on 12 May 2003, 12:11 p.m.,
in response to message #7 by Gene

I don't have the original PDF document either, but fortunately this plain text version of the relevant parts was laying around. Best.

---------------- Program listing ----------------

- SQRT is the square root function - X<>Y is the "X exchange Y" stack operation

01 STO 5 26 * 51 STO 5 76 + 02 1 27 - 52 g SQRT 77 - 03 STO 6 28 g SQRT 53 X<>Y 78 g X=0? 04 RCL 5 29 g GTO 00 54 1 79 g GTO 82 05 RCL 5 30 ENTER 55 - 80 g LSTX 06 CHS 31 ENTER 56 g X=0? 81 g GTO 66 07 STO 5 32 * 57 g GTO 59 82 RCL 4 08 RCL 6 33 1 58 g GTO 39 83 g X<=Y? 09 2 34 + 59 g n! 84 g GTO 89 10 + 35 g SQRT 60 STO 6 85 g LSTX 11 STO 6 36 / 61 RCL 5 86 8 12 Y^X 37 STO 4 62 - 87 * 13 g LSTX 38 3 63 g SQRT 88 g GTO 00 14 g n! 39 X<>Y 64 / 89 g LST X 15 / 40 ENTER 65 STO 5 90 CHS 16 + 41 * 66 RCL 5 91 g GTO 86 17 - 42 CHS 67 CHS 92 CLX 18 g X=0? 43 1 68 STO 5 93 ENTER 19 g GTO 22 44 + 69 RCL 6 94 * 20 g LSTX 45 g SQRT 70 2 95 CHS 21 g GTO 05 46 CHS 71 + 96 1 22 g LSTX 47 1 72 STO 6 97 + 23 1 48 + 73 Y^X 98 g SQRT 24 g LSTX 49 2 74 g LSTX 99 g GTO 37 25 g LSTX 50 / 75 /

You can test that the program is loaded correctly, and its accuracy by checking these results, shown as they are displayed in FIX 9 (f 9 in the 12C):

------------------------------------------------------------------- x Sin(x) Cos(x) Tan(x) Time ------------------------------------------------------------------- 0.1 0.099833417 0.995004165 0.100334672 6 sec. 0.5 0.479425539 0.877582562 0.546302490 7 sec. 1 0.841470985 0.540302306 1.557407724 9 sec. Pi/2 1.000000000 0.000000000 would div by 0 10 sec. 2 0.909297427 0.416146836 2.185039869 12 sec. Pi -7.098535e-12 1.000000000 -7.098535e-12 19 sec. ------------------------------------------------------------------- x ArcSin(x) ArcCos(x) ArcTan(x) Time ------------------------------------------------------------------- 0.1 0.100167425 1.470628906 0.099668661 10 sec. 0.5 0.523598775 1.047197552 0.463647607 12 sec. 1 1.570796327 0.000000000 0.785398163 15 sec. 10 - - 1.471127675 15 sec. 100 - - 1.560796637 18 sec. 1000 - - 1.569796326 18 sec. 1E10 - - 1.570796327 18 sec. -------------------------------------------------------------------

------------------- Usage instructions -------------------

As the 12C doesn't have user labels, these are the entry points to compute the functions, with the argument X assumed to be in the display (X-register):

----------------------------------------------------------------------- Function To compute, press: Input range ----------------------------------------------------------------------- Sin(x) GTO 00, R/S, X<>Y -5*Pi to +5*Pi Cos(x) GTO 00, R/S -Pi/2 to +Pi/2 Tan(x) GTO 00, R/S, / -Pi/2 to +Pi/2 ArcSin(x) GTO 37, R/S -1 to +1 ArcCos(x) GTO 93, R/S 0 to +1 ArcTan(x) GTO 30, R/S -9.99E49 to +9.99E49 the constant Pi/2 GTO 92, R/S no input required

------ Notes ------

- all angles are assumed to be in radians.

- no stack registers are preserved nor is X stored in LSTX, but R0-R3 are available at all times to store intermediate results or constants. The financial registers can be used as well.

- for Sin(x), Cos(x), and Tan(x) you can use f PRGM or GTO 01 instead of GTO 00. After any function is computed, the program pointer is left again at step 00, so you can compute a series of sines, cosines and tangents by simply pressing R/S.

- Sin(x) and Cos(x) are computed simultaneously. Sin(x) is left in the Y-register, and Cos(x) is left in the X-register (display), so you can obtain Tan(x) by simply pressing the [/] (division) key. If Cos(x) equals 0, you can't perform the division but must assume instead that Tan(x) becomes infinite

- the input range for Sin(x) goes from -5*Pi to +5*Pi, but large values of x (say > 2*Pi) result in reduced accuracy and increased running times, so you'd do well restricting your arguments to the range from -2*Pi to +2*Pi and reduce any larger ones to that range (by taking the remainder modulus 2*Pi).

                                                
12c platinum speed results using Valentin's all trig program
Message #9 Posted by Gene on 12 May 2003, 1:00 p.m.,
in response to message #8 by John Smith

Ok. Have tested these examples.

[pre] cosine test X 12c platinum original 12c 0.1 6 seconds 6 seconds 0.5 7 seconds 7 seconds 1 3 seconds 9 seconds (No, that's not a misprint!) PI/2 10 seconds 10 seconds 2 12 seconds 12 seconds PI 22 seconds 19 seconds (Not a misprint either)

Arc Sine test 0.1 7 seconds 10 seconds 0.5 9 seconds 12 seconds 1 13 seconds 15 seconds

Make of these what you will. :-) [\pre]

                              
Another 12c platinum speed test
Message #10 Posted by Gene on 12 May 2003, 11:58 a.m.,
in response to message #5 by Gene

Typed up the following bizarre program on both the original 12c and the 12c platinum. Note: to make it easier to read, I have put numbers all on one line.

360
n
10
ENTER
12
/
i
90000
PV
PMT
CHS
SQRT
1/X
3
Y^X
3
1/x
Y^X
1/X
ENTER
X (Note: I used the newfangled X^2 function on 12c platinum)
CHS
PMT
RCL
PV
5000
-
PV
FV
GTO 00

Times: Original 12c: 7 seconds, 12c platinum: 8 seconds.

Final answer: 99,186.99719. Interestingly, both agree to the last decimal point on the answer.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall