HP Forums
Sunday Afternoon Light TVM (HP-71B w/ MATH ROM) - 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: Sunday Afternoon Light TVM (HP-71B w/ MATH ROM) (/thread-9255.html)



Sunday Afternoon Light TVM (HP-71B w/ MATH ROM) - Gerson W. Barbosa - 10-08-2017 05:00 PM

The following finds i when FV = 0, given PV, PMT and n. This by no means intends to be either fast or accurate. Instead, it will get slower and slower as n increases and will lose accuracy as the ratio PV/PMT approaches 1. Anyway, for my personal needs two decimal places and n up to 3 might suffice. Exact close form solutions to this problem are possible for n up to 4, but the resulting expressions are by no means practical to be used in a light TVM program. The built-in solver might be faster regards the value of n, but I decided to see how PROOT would perform.

Code:

10 DESTROY ALL
15 INPUT "PV? ";P @ INPUT "PMT? ";M @ INPUT "N? ";N
20 OPTION BASE 0 @ DIM A(N+1) @ COMPLEX B(N)
25 DEF FNC(X,Y)=FACT(X)/(FACT(Y)*FACT(X-Y)) @ K=P/M @ A(0)=K
30 FOR I=1 TO N
35 A(I)=K*FNC(N,N-I)-FNC(N,I-1)
40 NEXT I
45 A(N+1)=0
50 MAT B=PROOT(A)
55 FOR I=1 TO N
60 IF REPT(B(I))>0 THEN 70
65 NEXT I
70 DISP "I = ";100*REPT(B(I));"%"               
75 END

>RUN
PV? 100
PMT? 55
N? 2
I = 6.59646009785 % (78)

>RUN
PV? 500
PMT? 101.51
N? 5
I = .501659795442 % (35)

>RUN
PV? 100
PMT? 50.01
N? 2
I = 1.33330372034E-2 % (0700)

>RUN
PV? 3229.10
PMT? 308.25
N? 12
I = 2.15465859368 % (76)

>RUN
PV? 3329.10
PMT? 1849.50
N? 2
I = 7.32122812931 %


I would surely be better off with an HP-12C or even with RPN-38 CX if I don't want to carry a calculator around :-)

I've found it easier to write an RPL version first on my HP 50g yesterday night, just before going to sleep. Who dare say RPL stands for RePelLent? (See, the code fits nicely in the box! :-)

Code:

%%HP: T(3)A(D)F(.);
\<< UNROT / DUP UNROT { } + OVER SWAP 0. ROT 1. -
  FOR i PICK3 PICK3 DUP i - 1. - COMB * PICK3 i COMB - +
  NEXT 0. + UNROT DROP2 AXL PROOT 1.
  DO GETI RE
  UNTIL 0. >
  END 1. - GET RE 100. *
\>>

3329.10 1849.50 2 LTVM --> 7.32122812931