The Museum of HP Calculators

HP Forum Archive 08

[ Return to Index | Top of Index ]

STUPID BUTUSEFUL CHALLENGE #879
Message #1 Posted by thibaut.be on 5 July 2002, 4:47 a.m.

The formula for constant annuity (TVM reimbursement) is :

a = PV * i / (1-(1+i)^-n)

write a program in as few possible steps to solve this equation, where you have previously entered the following variables in the stack : PV (= present value or lended amount, i (= interest (not in %, ie 6% = .06), n (number of payments

NB : European people : i has to be converted from the basic rate. If rate is anuual and payments are monthly, then im = 1-(1+iy)^(1/12)

American people : the shown rate is different from the yield, but the monthly rate is calculated by dividing the annual rate by 12, so im=iy/12

Thibaut

      
Re: STUPID BUT USEFUL CHALLENGE #879
Message #2 Posted by thibaut.be on 5 July 2002, 5:21 a.m.,
in response to message #1 by thibaut.be

Oops, I posted the message above to fast.

- the PV, n and i vlaues can be stored wherever you want - hint : use no register (sto and rcl cost bytes !), but do use the stack. BTW, this is an excellent stack exercice.

My solution is 15 steps long, including LBL/RTN. Who give a better one ?

It could be 17 steps long with a 12C for the rollup function does not exist in the 12C (you spend 2 more bytes * 2) but the lbl and rtn funtions do not exist either (you save 2 bytes)

Amazing how fast the answer is given on a 41C (< 1sec) and on a 12C (<2.5 sec, v. <2 sec with the solver)

Enjoy !

            
13 steps - listing included...don't read unless you want to see it!
Message #3 Posted by Gene on 5 July 2002, 4:58 p.m.,
in response to message #2 by thibaut.be

Ok, to make up for NOT READING the earlier challenge completely (I used a numeric key), I have a 41c style solution with 13 steps, including LBL and RTN.

My inputs are n, PV, and i in the Z, Y, and X registers. I assumed that n is total number of payments and i was the periodic interest rate...if the payments are monthly then i is the monthly interest rate.

Interestingly, I have 15 step solutions for PV, n, i and PV, i, n as the input order.

LBL 01 x Lastx 1 + RUP (Roll Up) CHS Y^x 1 - CHS Divide RTN

That seems to work. Anyone less than 13? Gene

                  
Re: 13 steps - listing included...don't read unless you want to see it!
Message #4 Posted by Ed Martin on 5 July 2002, 8:51 p.m.,
in response to message #3 by Gene

This is cheating ... a bit.

If you put -n on the stack instead of N, you can do it in 12 steps:

LBL 01 * LASTx 1 + RUP y^x CHS 1 + / RTN

- Ed

            
My solution...
Message #5 Posted by thibaut.be on 6 July 2002, 2:04 a.m.,
in response to message #2 by thibaut.be

Also 13 steps, without LBL and RTN, with n in Z, PV in Y and i in X :

LBL A ENTER Roll Down * Roll Up 1 + Roll Up CHS y^x 1 - CHS / RTN

      
Re: STUPID BUTUSEFUL CHALLENGE #879
Message #6 Posted by Jim Kimes on 7 July 2002, 6:07 p.m.,
in response to message #1 by thibaut.be

I suggest that when such challenges are posted--and they can be quite useful--a solved example be included so that the challengees will know positively they've understood the problem and exactly what kind of problem it is they're challenged to solve. In this case I could have produced a formula but I wouldn't have known for sure that the formula was exact without a sample by which to proof my work. Thanks.

            
Re: STUPID BUTUSEFUL CHALLENGE #879
Message #7 Posted by thibaut.be on 8 July 2002, 11:25 a.m.,
in response to message #6 by Jim Kimes

example :

You purchase a house for $500.000. You pay it back in 15 years. Rate is 5.5/year.

Month rate is .05/12=0.42%/month. 15 years is 180 month

Key in 180 ENTER 500.000 ENTER .0042 R/S (or XEQ...)

Your should read a monthly payment of 3.964,39 per month...

                  
Re: STUPID BUTUSEFUL CHALLENGE #879
Message #8 Posted by Jim Kimes on 12 July 2002, 5:38 p.m.,
in response to message #7 by thibaut.be

Thanks for the example. Helps immensely.

      
Re: STUPID but Useful Challenges
Message #9 Posted by Paul Brogger on 8 July 2002, 10:39 a.m.,
in response to message #1 by thibaut.be

I would think that the creative finance people from Enron and WorldCom could put their vast experience to use and contribute a few helpful hints under this Subject line . . .


[ Return to Index | Top of Index ]

Go back to the main exhibit hall