![]() |
Accurate TVM for HP 35s - 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: Accurate TVM for HP 35s (/thread-120592.html) |
Accurate TVM for HP 35s - Miguel Toro - 08-06-2007 Hi, I wrote this program for my HP 42s. I wanted to adapte it for the HP 35s and here is the routine. You have to assign the routine with FN= and then to solve for the variable you want. As you know, the Hp 35s has no LN(1+x) function included, so I implemented what is defined in the HP-15C Advanced Functions Handbook:
if u= (1+x) I tried the following examples to compare against the 35s manual's equation, my HP 12C (made in USA) and my HP 12cp 25th annyversary:
Example A: All improvements are welcome as well as other examples to test it. Regards, Miguel
Edited: 8 Aug 2007, 6:35 a.m. after one or more responses were posted
Re: Accurate TVM for HP 35s - Gene Wright - 08-06-2007 Great job, Miguel!
Now, right this up and submit it to Datafile as well and you'll be a published author in the magazine too. :-)
Re: Accurate TVM for HP 35s - sjthomas - 08-06-2007 Is this listing correct? I've proofed my input of this program three times and it matches the posted listing, but I get CK=D44E and LN=127 and the program errors with an OVERFLOW when I run it.
Re: Accurate TVM for HP 35s - Miguel Toro - 08-06-2007 You are correct. I did not write the last version, but I put the checksum of it. I corrected the listing and It should work. Thanks,
Miguel
Re: Accurate TVM for HP 35s - Vincze - 08-07-2007 Good Morning Miguel. This is very interesting. One question I have though is was reason you store as FN= so you could choose what variable you wish to solve for? Can you store multiple FN or just one?
Also, there are about 10 (if I remember correctly) TVN formulas for different things (future value of lump sum, present value of annuity, etc), and then based on various criteria (annual compounding, compounded n times per year, and continuous compounding). I think I might and try and tackle those as a starter to learn how to program with 35s. I working on my MBA (is that funny. Stupid Hungarian working on MBA when he can not even speak language very well).
Re: Accurate TVM for HP 35s - ECL - 08-07-2007 Miguel, I also tried keying it in, and get:
Checksum 45DC Also, I'm not quite sure if I understand the methodology behind your INPUTs. How can I decide which variable to solve for? I'll mention that I am not new to programming on HP machines, just forgive me if I've missed a fundamental point. Also, as of now I also get OVERFLOW when I XEQ it. Thanks,
ECL
Re: Accurate TVM for HP 35s - Miguel Toro - 08-07-2007 Hi Vincze, You have to tell the calculator which program you want to solve. You do that by selecting the program label with the "FN=" key. The solver will continue to use the program selected as long as you do not change to another program (with another FN= assignment for a different label). Once called, Solver will ask for the unknown variable and it will ask for values for the rest of the variables that have INPUT instructions. Also, most of the things that you mention can be solved already with this routine, so you just have to enter the data as it is needed by the problem. That is the beauty of this equation.
Example 1: Future value of a lump sum.
Keystrokes:
Example 2: Present value of annuity.
Keystrokes: And so on... Regards,
Miguel Edited: 7 Aug 2007, 12:57 p.m.
Re: Accurate TVM for HP 35s - Miguel Toro - 08-07-2007 I keyed the program and it is correct as it is in the post. Please verify lines: T0016 x<>y this is switch x and y. T0019 X<>Y? this is compare if x is different than y. The confusion may come from there. To solve the program just assign it to FN= and next you solve it. You do not XEQ it!. See the keystrokes:
[LS][FN=] The solver will ask for the unknown variable for which you want to solve, and it will ask for values for the rest of the variables. Regards,
Miguel Edited: 7 Aug 2007, 1:03 p.m.
Re: Accurate TVM for HP 35s - Vincze - 08-07-2007 Miguel, thank you my friend for the example. I see now how FN= work now. One question I do have though is what is the formula i' for? In MBA, I aware of P/i*(1-(1+i)^-n)+F*(1+i)^-n+B=0 to solve for TVM, assuming that this loan payment and payment at end of period and not beginning. For beginning (or lease generally) there different formula. Yours account for that nicely, but I do not understand the i' formula. I would think that if not needed, program might be shorter and more efficient. Let me think through and I will post back.
Slightly Shorter TVM program - Vincze - 08-07-2007 Okay, I try my hand at first program. I must admit, harder than I thought. Let me state up front though, that this getting wrong answer **EDIT:(the below program has been corrected)**, so I need help of members to see where I go wrong.
First, I use the following formula: P/I*(1-(1+I)^-N)+F*(1+I)^-N+B
I then collect like terms and get: (1-(1+I)^-N)*P/I+(1+I)^-N *F+B
Variables are same as above program, but I is in the factor of %/(n payments per year), so if interest be 5% and 12 payments per year, then .05/12 = .004167 = I My **CORRECTED** program steps are below: T001 LBL T I wonder if I have order of operator error someplace. I look, but sometime it better if fresh eyes look at to see my mistake. If the following variables are entered, the result should be -1588.9920 when solving for P. ...but with above formula, I get -1233.432. **EDIT** Corrected formula yields correct value of -1588.9920.
Edited: 7 Aug 2007, 4:51 p.m. after one or more responses were posted
Re: Slightly Shorter TVM program - Miguel Toro - 08-07-2007 Try this:
T001 LBL T And try to solve for the extreme cases from my original post. What do you get? :-)
Miguel
Re: Slightly Shorter TVM program - Vincze - 08-07-2007 Yes, I see my error on line T015, and was going to post correction, but you beat me to it. I forgot to multiply there.
With your extreme case example, I don't think you would use this formula normally for continuous compounding (first example), and with second example, yes it extreme, but not realistic. Edited: 7 Aug 2007, 5:40 p.m.
Re: Accurate TVM for HP 35s (one line "program") - Chuck - 08-07-2007 This isn't a program, but this is what I came up with a few weeks ago while camping. It's slightly different than the example from the owners manual; this is the form that I have the compounding interest formula and annuity formula memorized.
Press EQN, then enter the equation... Q x (1 + R/N)^(N x T) + P x ((1 + R/N)^(N x T) - 1) / (R/N) + BDirectly above this equation you could enter the "Equation" TVM as a title to the TVM formula.
Q = present value This is only for annuities due, (ie, end on period compunding) for simplicity. Pull up the equation, press solve, the letter, and enter the known values as prompted.
CHUCK Edited: 7 Aug 2007, 5:14 p.m.
Re: Slightly Shorter TVM program - Miguel Toro - 08-07-2007 The point is that with the program I posted you mantain enough precision to be sure of obtaining accurate results, even in extreme cases where you have too small a interest rate that it can loose decimals because of the precision of the calculator. That is why we make the change in the formula using:
(1+i)^n = e^(n*ln(1+i)) ln(1+i) lets us to preserve accuracy, so the hp 35s can come closer to dedicated calculators as the hp 12c and expands its usefulness. Regards, Miguel
Edited: 7 Aug 2007, 6:41 p.m.
Re: Slightly Shorter TVM program - Vincze - 08-07-2007 My friend Miguel, I mean no disrespect, but I think your program very good, but again unrealistic in real world situation. Yes, if we have continuous compounding with continuous funding, it does do better than mine, but the basic TVM formula has not changed much in the last 100 years. The reason being is that interest rates have not reached minimal numbers like your program simulate. Yes, in theory it is possible, but not realistic. I think your program a very good example of what we call didaktikus in hungarian (I apologize, I do not have hungarian english dictionary with me to find english same word). It mean example, or teaching. Again it possible to have money continuously grow and add .01 cent continuously, but what bank could ever do that? I think for most real world example, it might be a bit more than need and if I be banker I may want shorter program that be faster. Just my opinion. I hope there no hard feeling. I still interested though in your formula, as I have never seen the I' portion as when I plan continous equations we do it much differently with much shorter formula.
Thank you again my friend though for enlighten me in different way of doing same thing and letting me get feet wet in HP programming.
Re: Slightly Shorter TVM program - Paul Dale - 08-07-2007 Quote: I imaging that "didaktikus" translates roughly to "didactic" or a derative form. Not that I understand any Hungarian :-)
Re: Accurate TVM for HP 35s - tony (nz) - 08-07-2007 Miguel, Thank you for the excellent program. Note that Example A needs not 10 but 10/N at the I prompt :-)
Best, Tony
Re: Accurate TVM for HP 35s - Gerson W. Barbosa - 08-07-2007
Examples
Should I return my HP-80 (1247A46954) ? :-)
Re: Accurate TVM for HP 35s - Miguel Toro - 08-08-2007 Ups! Thanks Tony.
Re: Accurate TVM for HP 35s - Miguel Toro - 08-08-2007 Hi Gerson, If you don't want it any more...I accept donations! ;-)
Re: Slightly Shorter TVM program - Vincze - 08-08-2007 Quote:I guess I am still hung up on this part of the formula. Can you point me someplace that discuss this further. Obviously, accuracy a big concern, but in my studies, I have not seen this. Re: Slightly Shorter TVM program - Vincze - 08-08-2007 Quote: Paul, I look in my dictionary this morning and it does not have didaktikus in there to translate to english, but when I look up the word "didactic", the definition is very close too what I mean, so they must be related.
I will email someone who has better Hungarian / English dictionary to double check. Thank you for your help. I see I learn new English word today. Yesterday I learn "ameliorate", or to make better.
Re: Accurate TVM for HP 35s - Gerson W. Barbosa - 08-08-2007 Hello Miguel, I am not interested in financial calculators, unless they're programmable and miss trigonometric functions. But I will keep this one until one friend of mine confirms he wants to trade it with something else. An HP-35s with your TVM program might be enough for all my modest financial needs :-) Best regards,
Gerson.
Re: Slightly Shorter TVM program - Miguel Toro - 08-08-2007 Hi Vincze, In my original post, you can click on two excellent links that explain the matter further. You can also see the page 181 of the HP 15c "Advanced functions handbook" for this specific subject, or the entire chapter "Accuracy of numerical calculations" for discussions about different types of problems. If you do not have the book, the best alternative is the DVD from the museum, of course. :-)
Miguel
Re: Slightly Shorter TVM program - Vincze - 08-08-2007 My friend Miguel, I just read the 15C book example. So what it sounds like is that this deals with convexity and duration vector. Very interesting. It should be noted, that TVM calculation are basically just estimates. Granted, banks want these as accurate as possible, but I think even with convexity and duration vectors, it will still be an estimate, but obviously much better. The TVM calculation is basically a polynomial, as because of that it will have roots (yes, plural. financial calculators only will find the one, but if you solve the formula and use the standard quadratic equation to solve for the unknowns, you will see what I mean). I wonder if there is a way to harness the polynomial in a different way to get an *even* more accurate solution.
Very interesting my friend. Thank you for the enlightenment. Edited: 8 Aug 2007, 10:08 a.m.
Re: Accurate TVM for HP 35s - Etienne Victoria - 08-08-2007 Hello Gerson, "Should I return my HP-80 (1247A46954) ? :-)"
My heart sinks.... Kindest regards from France!!!
Etienne
Re: Accurate TVM for HP 35s - Gerson W. Barbosa - 08-08-2007 Quote: I won't, mon ami. Just email me :-) Warm regards from Brazil, Gerson.
Re: Slightly Shorter TVM program - John H Meyers - 08-09-2007 Quote:I don't know how 35s does internal computations, but on most past HP-designed series, (1+i)^nis calculated more accurately than e^(n*ln(1+i))because it is using exactly the same formula internally anyway, but is retaining extended precision, which is lost when the intermediate "user" results are rounded to lesser precision.
In particular, on a calculator which always keeps the same number of digits in intermediate results, the moment we add 1 to a very small value of i, only the leading significant digits of the original i remain, and we have already lost any chance to get a completely accurate final result from the remaining steps.
This happens no matter which way we try to calculate the expression above, but it's worse when we take the log and multiply etc. ourselves, because then our intermediate results get rounded to "user" precision at each step, including the log and multiply, whereas when the calc does it, it can do the log, multiply and final EXP using greater internal precision than we can.
To retain precision for very small "i" and large "n" one really needs the special internal LNP1 and EXPM functions, which for small arguments use series expansions that omit the first term. I'm working on a bit longer document about this, at least as it would apply to numerical methods on older series; perhaps 35s uses different internal numerical recipies, and if so, any experiments which shed light on that would be of interest.
TVM equation principles - John H Meyers - 08-09-2007 This long-winded excursion explores the merits of different equations
Some principles to consider:
o Reasonable initial guesses should always send the root hunter
Suggested formulas of general type 'f(n,i%yr,PV,PMT,FV,PYR,Begin?)=0'
Sometimes we see the FV term having no other variables
Solving for N can also produce a surprise, when for some initial guesses,
Among the versions of this formula which I have tried,
But in this form of the equation, unlike some other forms,
A final tweak which seemed to improve solving for N
o It's useful to confine the search for an interest rate
However, the numeric solver isn't conscious of this,
If a new variable is introduced, say j=LN(1+i),
Another rather elegant feature of this remapping is that if you were
A very small rounding error may have to be accepted as a trade-off
o Cases involving large N and small I present a special challenge to accuracy.
In those cases, directly computing such expressions as '(1+i)^n-1'
Rewriting '(1+i)^n-1' as 'EXPM(n*LNP1(i))' and
Note also that with the above-suggested change of variable, we have
If anyone would like to try out various equations on a "breadboard rig," @ Testing equations on HP48/49/50 (ignoring the built-in TVM solver :)
Modern HP financial calculators, as you know,
I use this same set of values in my HP32Sii and HP42S formulas,
I was going to append my HP32Sii formula and HP42S program, --
Edited: 9 Aug 2007, 5:54 a.m.
|