Post Reply 
TVM solve for interest rate, revisited
06-09-2024, 04:46 PM
Post: #32
RE: TVM solve for interest rate, revisited
I did* translate your code into R for use with the (R)mpfr library (in a very clunky manual way - it was only to serve the basic purpose of getting more precise results than the DM42/Plus42 can output).

But just for fun, here is it with the problem above, initial guess of 10%, solving with 1000 bits of precision:

Code:
  iter         i              f             f0            eps
1    1 -0.524179   1.189774e+03   0.000000e+00  -6.241790e-01
2    2 -0.500000  -4.835808e+01   1.189774e+03   2.417904e-02
3    3 -0.500000  -2.586899e-11  -4.835808e+01   1.293450e-14
4    4 -0.500000  -2.251961e-35  -2.586899e-11   1.125981e-38
5    5 -0.500000  -1.706569e-83  -2.251961e-35   8.532843e-87
6    6 -0.500000 -9.800526e-180  -1.706569e-83  4.900263e-183
7    7 -0.500000   0.000000e+00 -9.800526e-180   0.000000e+00
8    8 -0.500000   0.000000e+00   0.000000e+00   0.000000e+00

With i as:

Code:
1 'mpfr' number of precision  1000   bits
[1] -0.4999999999999772626324556157894819480015601928133859453506649561424082849
50469649920734546388757663388950218950670857339905568445420132396647739217005786​
23316123318913635334886714726022977608726558724596098528753080203217196000004117​
8985411578382337606374842897420492915931795226261455970009197588717915

* probably before your changes above, though I don't think you've changed the algorithm of the newton method?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: TVM solve for interest rate, revisited - dm319 - 06-09-2024 04:46 PM



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