Post Reply 
Request TVM formula guidance
12-02-2014, 05:33 AM
Post: #1
Request TVM formula guidance
I am writing code for an HP12C calculator sim as a personal project for learning Java.
All gui components are complete and working, as are all scientific, math, statistics, dates and all buttons except the TVM buttons which are in process.

Now its down to the code for solving compound interest for amortized loans and I have had good results, including the capability for solving 2 roots. My only concern is that I have actually written a good compliment of f(x) where f'(x) is the derivative.

The results appear precise and a match to a variety of real and simulated calculators.
I just need to know if I have a correct derivative. ...if only I had taken Calculus...

Could someone take a look, if they like, and let me know if I am on the right track.

This is psuedo-Java-code of what I am using, residing within a loop.

K = 0 (month end interest computation, else 1 for beginning)
PYR = number of annual compounding periods x years, ie: 12
I = initial guess followed by storing computed guesses (display format 5 for 0.05)
R = I / 100 / PYR
TVM values supplied: N,PMT,PV,FV,PYR,K
Solve for I using Newton's method in iterative code.

// formula from the hp12c manual, solves to 0 for matched I converted to R, used below
f(x) = PV + (1+R*K) * PMT * ((1-(1+R)^-N)/R) + FV * (1+R)^-N

// the derivative as best I know
f'(x) = PV + (1+R*K) * PMT * [1/N * (1-(1+R)^-(N-1)) / (1/R)] + FV * [1/N * (1+R)^-(N-1)]

// compute for +I
I = I - f(x)/f'(x)

// or for -I
I = I + f(x)/f'(x)

// breakpoint on difference of prior computed I and current I is <= 5e-12 for fractional I | I < 1 percent
// or computed I <= 5e-15 for I | I >= 1 percent

Thanks
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Request TVM formula guidance - iMatt04bit - 12-02-2014 05:33 AM
RE: Request TVM formula guidance - Dieter - 12-03-2014, 09:17 PM
RE: Request TVM formula guidance - Dieter - 12-11-2014, 06:36 PM
RE: Request TVM formula guidance - Dieter - 12-14-2014, 04:24 PM
RE: Request TVM formula guidance - Dieter - 12-17-2014, 01:21 PM
RE: Request TVM formula guidance - Dieter - 12-21-2014, 06:14 PM
RE: Request TVM formula guidance - Dieter - 12-25-2014, 12:42 PM
RE: Request TVM formula guidance - Dieter - 12-29-2014, 07:47 PM



User(s) browsing this thread: 2 Guest(s)