HP Forums
12C and its financial algorithms - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: 12C and its financial algorithms (/thread-36586.html)



12C and its financial algorithms - Eduardo - 06-18-2003

I found a very interesting article by a UC Berkeley math & engineering professor (W. Kahan) about calculation roundoff errors and poor processor architectures. What's interesting is that he compares HP with TI financial calcs, and he was actually involved in the coding of the *original* 12C's algorithms. I'm posting this as a follow-up on the controversy about the 12C Platinum's "solving for i". Dr. Kahan's article (pp. 14-19) discusses this issue quite in depth (for the original 12C). You can be quite sure the 12C Platinum does not use his beautiful ideas or it would be *at least* as fast as the 12C. I wouldn't be surprised if HP simply "lost" the original coding ideas used for the 12C and tried to reinvent the wheel (and if you read the article, you'll see reinventing *this* wheel isn't quite as simple as it initially appears). The article, called "Mathematics Written in Sand", is linked to from Dr. Kahan's web page at:

http://www.cs.berkeley.edu/~wkahan/

The direct URL is:

http://www.cs.berkeley.edu/~wkahan/MathSand.pdf

Eduardo


Re: 12C and its financial algorithms - Luc Chanh Truong - 06-18-2003

Thank you alot, Eduardo, for your information. It's very interesting.




Re: 12C and its financial algorithms - Tony - 06-19-2003

Yep, that's a great article. The 12CP is really a very interesting machine. Every day I see a new bug!<G>. Today I tried n=1 i=-.001 PV=100 PMT=0 and solved for FV=-99.999 which is correct. But i=-.0009 gives FV=100.0009. Yes, plus 100.0009! The answer should be -99.9991. I cannot imagine the coding that would do this magic. The old 12C does this correctly, so it is not something copied over. yesterday I noticed the 12CP does try and cheat when solving for i - but it only goes ahead and does it if the solution is exact.
Today's one only happens if i is between -.001 and 0.


Re: 12C and its financial algorithms - Tony - 06-19-2003

On page 15 of Prof kaplan's "Maths in the Sand" is a "Penny for your Thoughts" example with n=31,516,000 i=3.170979198 E-7 PV=0 PMT=-.01 END: solve for FV=331,667.0067. The 12CP resolves for i in 280 seconds giving i=3.107401823 E-7. That's within about E-4%. The 12C gives 3.197401823 -7 which is 1% out, but it only takes a few seconds. All is not lost on the 12CP though - i did a 250 (the limit, due to a bug) line i-solve program that never seems to take longer than 40 seconds - so the 12CP runs the prog well - and for the above case it resolves the i exactly!! Probably a fluke, but shows what the 12CP can do.


Re: 12C and its financial algorithms - Tony - 06-19-2003

whoops the 12CP gives 3.170982000 E-7 in 280 seconds - a pretty good answer in the end. Only 2.8E-13 too high or about E-4 %

Edited: 19 June 2003, 4:00 a.m.


Re: 12C and its financial algorithms - hugh - 06-19-2003

280 seconds! wait! whats's this. here comes the hp9g, cover flapping in the wind...

"I'll save you rpn mortals from evil tvm errors..."

"finding FV is easy with my 24 digit precision. don't panic kids, i'll just use the textbook formula fv=-amt*((1+i)^n-1)/i"
60*60*24*365->N
.1/N->I
.01*((1+I)^N-1)/I = 31,667.0067

"ah! that was easy, now to solve for I in only 5 seconds.. just whisk together a quick solver..."

INPUT L,H,E;
E=10^(-E)
X=L
GOSUB PROG 9;
A=Y
Lbl 1:
IF (ABS(H-L) < E*ABS(H)) THEN { GOTO 2; }
X=H
GOSUB PROG 9;
B=Y
C=H-B*(H-L)/(B-A)
L=H
A=B
H=C
GOTO 1;
Lbl 2:
X=C
END

"and the solve-for subroutine..."

Y=((1+X)^31536000-1)*.01/X
Y=Y-331667.0067
END

"put in L=1e-30, H=1e-7, E=8 and presto!"

x=3.1709792e-9 which is correct.


Gee, thanks 9g, i'll never doubt you again.


Re: 12C and its financial algorithms - eel - 06-28-2003

>FV=-99.999 which is correct. But i=-.0009 gives FV=100.0009

I tried this on my 17BII, and the answer I got is FV=100.009!


Re: 12C and its financial algorithms - Tony - 06-29-2003

here the 17bii is fine, n=1,i=-.0009,pv=100,pmt=0 gives fv=-99.9991.