Post Reply 
(15C) Halley's Method
06-11-2022, 04:12 PM
Post: #3
RE: (15C) Halley's Method
Halley's Irrational Formula may cause sqaure root of negative number problem.

(01-07-2020 06:13 PM)Albert Chan Wrote:  Example, for N=30, PV=6500, PMT=-1000, FV=50000, we have I = 8.96% or 11.10%

Does anyone knows what returns should be reported for above investments ?

Halley's rational formula for rate search work, without issue.

lua> n,pv,pmt,fv = 30,6500,-1000,50000
lua> i1, i2 = edge_i(n,pv,pmt,fv)
lua> i1, i2
-0.02     0.15384615384615385
lua> g1 = loan_rate2(n,pv,pmt,fv,i1)
lua> g2 = loan_rate2(n,pv,pmt,fv,i2)
lua> for i = 1,6 do print(i, g1(), (g2())) end
1   0.05032222218969118    0.11874137324380304
2   0.08034524496312957    0.11136968662548538
3   0.0889289402959179     0.11100337818114
4   0.0896051698287111     0.11100328640549177
5   0.08960585626123155    0.11100328640549177
6   0.08960585626123234    0.11100328640549177

Halley's irrational formula failed, even on first try, at i = -0.02
Halley's modified slope = (f' + sign(f')*sqrt((f')^2 - 2*f*f'') / 2

lua> f0 = 1356.1628502335457 -- i = -0.02
lua> f1 = -26468.743095455087
lua> f2 = 280416.32885371713
lua> f1*f1 - 2*f0*f2
-59986054.527367234

Perhaps it is because of negative guess rate ? No !
Even with guess i = 0.07, we still hit square root of negative number problem.

lua> f0 = 53.131798377782616 -- i = 0.07
lua> f1 = -4261.51788308051
lua> f2 = 171458.18285005045
lua> f1*f1 - 2*f0*f2
-59228.53500474244
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(15C) Halley's Method - Thomas Klemm - 02-26-2022, 11:09 AM
RE: (15C) Halley's Method - Albert Chan - 02-26-2022, 03:48 PM
RE: (15C) Halley's Method - Albert Chan - 06-11-2022 04:12 PM
RE: (15C) Halley's Method - Albert Chan - 06-14-2022, 06:22 PM
RE: (15C) Halley's Method - Gil - 06-14-2022, 01:20 AM
RE: (15C) Halley's Method - Albert Chan - 06-14-2022, 02:59 AM
RE: (15C) Halley's Method - Albert Chan - 06-18-2022, 03:37 PM
RE: (15C) Halley's Method - Gil - 06-14-2022, 07:33 AM



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