Looking for TVM formulas
|
04-04-2014, 05:23 PM
Post: #21
|
|||
|
|||
RE: Looking for TVM formulas
(04-04-2014 02:07 PM)Dave Britten Wrote: Awesome, I used Thomas' suggestion for calculating (1 + i%) ^ n - 1 using the more accurate e^x-1 formula, 2 * sinh(x / 2) * e ^ (x / 2), and now for the Susan example, my TI-95 program is giving me FV = -333,783.3499486. I've used that in Jeff Kearns' program for the HP-15C: Code: 001 - 42,21,15 LBL E Now I get 333,783.3500 instead of 333,783.3508. Cheers Thomas |
|||
04-04-2014, 09:44 PM
Post: #22
|
|||
|
|||
RE: Looking for TVM formulas
(04-04-2014 02:07 PM)Dave Britten Wrote: Program size is currently 478 steps, and I figure there will be another 150-200 when all that is implemented. Wow! That is quite the program... Just FYI, the total program length (including Solver) for the HP-29C or HP-11C is 71 steps in length. Granted, it does poorly (if at all) at solving for interest. The program size for calculators with built-in solvers is substantially smaller (and finds solutions for periodic interest rates). What does your program do exactly? I thought you wanted a TVM solver. Regards, Jeff |
|||
04-04-2014, 10:12 PM
(This post was last modified: 04-04-2014 10:13 PM by Dave Britten.)
Post: #23
|
|||
|
|||
RE: Looking for TVM formulas
(04-04-2014 09:44 PM)Jeff_Kearns Wrote:(04-04-2014 02:07 PM)Dave Britten Wrote: Program size is currently 478 steps, and I figure there will be another 150-200 when all that is implemented. TVM solver, mostly. The TI-95 has lots of RAM to work with, for a keystroke programmable calculator (about 8KB), and the default partitioning gives you about 1000 steps/bytes of work RAM to use for coding. Programs can be saved/loaded/executed from the file partition, which defaults to about 5KB (5000 steps or so). There are also instructions to save ranges of registers into the file memory for later retrieval. With default settings, you get 125 storage registers, all addressible directly or indirectly (any register can be used for indirection). I think it's also possible to shrink file space to zero, and rely on an 8/32 KB expansion module for your file storage, but you'd have to be working with some enormous programs to need that. Off the top of my head, these are the routines in the program so far: 1. Main menu - Allows accessing the TVM menu, or selecting Begin/End modes. Amort will be accessible from here when I implement it. 2. TVM menu - Shows the 5 TVM variables, and allows storing a value into each, or requesting solutions. The 95 allows testing for the INV prefix key being used to modify a soft key, so each of the five soft key handlers checks for it, calls one of five "solve" routines if needed, then puts the display value into the selected variable. 3. Five "solve" routines - Three of these are direct solutions (PV, PMT, FV), and the other two prepare... 4. ...The numeric solver - A straight port of the HP 20S solver, with a couple changes specific to this progra. It chokes on overflows trying to solve for n or i% in the Susan example, so I probably ought to replace it. Works okay for 'typical' problems, but isn't particularly fast, as it's lacking any initial guess logic (just starts at 1). 5. ln(1+x) - Uses numeric methods discussed in this thread. 6. e^x - 1 - Ditto. 7. (1 + i%)^n - Uses the ln(1 + x) routine for greater accuracy. Needed by all of the solution equations. 8. ((1 + i%)^n) - 1 - Also uses e^x - 1, and again needed by the solutions. 9. i% Routine - Returns i% / 100 for calculations. Needs to have some of the repeat calls optimized away. 10. Begin/End Routine - Returns 1 or 0 if Begin or End is selected, respectively. 11. Solver equation - TVM equation with one side solved for zero, for use with numeric solver routine. So, the (somewhat) redundant direct solutions, menu handlers, math utility routines, and included numeric solver explain the size. Also, the TI needs something like three bytes (steps) for goto, gosub, STO, RCL, comparison tests, and other instructions that require an argument, to allow for the full three or four digits used in the addresses. Any functions prefixed with INV will also use another byte for the prefix. |
|||
04-05-2014, 09:58 PM
(This post was last modified: 04-05-2014 10:22 PM by Dieter.)
Post: #24
|
|||
|
|||
RE: Looking for TVM formulas
(04-04-2014 10:12 PM)Dave Britten Wrote: 3. Five "solve" routines - Three of these are direct solutions (PV, PMT, FV), and the other two prepare... Hm, why do you think that there is no direct solution for n and an iterative approach is required? Consider the basic TVM formula you already posted: PV * (1 + i)n + PMT * ((1 + i)n – 1)) * ((1 / i) + B) + FV = 0 Then (1 + i)n – 1 = –(PV + FV) / (PMT * (1 / i + B) + PV) And thus, using ln1+x for best accuracy: n = ln1+x(–(PV + FV) / (PMT * (1 / i + B) + PV)) / ln1+x(i) Or a bit more formal: \(\large n = ln (1 - \frac{PV + FV}{PV + PMT (\frac{1}{i} + B)}) : ln (1 + i)\) Try the Susan example: (1+i)n – 1 = (–(0 + -333783,35)) / ( 0,01 * (1/3,567351598 E-9 + 0) + 0) = 333783,35 / 2803200 = 0,1190722567 ln1+x(0,1190722567) / ln1+x(3,567351598 E-9) = 31536000 Dieter |
|||
04-05-2014, 11:38 PM
Post: #25
|
|||
|
|||
RE: Looking for TVM formulas
(04-05-2014 09:58 PM)Dieter Wrote: Hm, why do you think that there is no direct solution for n and an iterative approach is required? Oh, I figured there was one, I just hadn't found/derived it yet, so I was feeding it through the numeric solver for now. Thanks for posting that, it should prove useful. |
|||
04-06-2014, 07:46 PM
(This post was last modified: 04-06-2014 07:50 PM by Dieter.)
Post: #26
|
|||
|
|||
RE: Looking for TVM formulas
(04-02-2014 05:18 PM)Thomas Klemm Wrote: You could use \(e^x-1=2 \cdot sinh(\frac{x}{2}) \cdot e^{\frac{x}{2}}\) instead. Since we're at it: hyperbolics can also be used for ln1+x. \(ln(1+x) = 2 \cdot artanh(\frac{x}{x+2})\) Seems to work well if x is not too large so that the artanh-argument does not get too close to 1. Dieter |
|||
04-09-2014, 01:36 PM
(This post was last modified: 04-09-2014 02:15 PM by Dieter.)
Post: #27
|
|||
|
|||
RE: Looking for TVM formulas
(04-06-2014 07:46 PM)Dieter Wrote: Since we're at it: hyperbolics can also be used for ln1+x. This one seems even better and does not have problems with very large x: \(ln(1+x) = arsinh(\frac{x^2+2x}{2+2x})\) For better numeric accuracy this can be written as \(y = \frac{x}{2}; z = y + \frac{y}{2y+1}\) \(ln(1+x) = arsinh z\) With \(z \rightarrow \infty, arsinh z \rightarrow ln 2z\) and \(z \rightarrow \frac{x+1}{2}\), so that \(arsinh z \rightarrow ln(1+x)\). Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)