Post Reply 
HP 17B Solver - another ARCTAN(Y/X) approximation
08-19-2021, 02:42 AM (This post was last modified: 08-19-2021 12:05 PM by Albert Chan.)
Post: #13
RE: HP 17B Solver - another ARCTAN(Y/X) approximation
For improving x = atan(y), it turns out Halley's method is just as simple as Newton's mehtod.

f(x) = tan(x) - y
f'(x) = sec(x)^2
f''(x) = 2*sec(x)^2*tan(x) = 2*tan(x)* f'(x)

Let t = tan(x):

Newton correction = f / f' = (t-y) / (1+t*t)
Halley's correction = f / (f' - (f''/2) * (f/f')) = (t-y) / (1+t*t - t*(t-y)) = (t-y)/(1+t*y)

lua> y = 3
lua> x = atan(y)
lua> x
1.2490457723982544
lua> g = x + 0.001 -- guess
lua> t = tan(g)
lua> g - (t-y)/(1+t*t) -- Newton's method
1.249048773063921
lua> g - (t-y)/(1+t*y) -- Halley's method
1.249045772064921
lua> g - tan(g-x)
1.249045772064921

Halley's correction here is really tan(ε) = ε + ε^3/3 + ... = ε + O(ε^3)

→ atan(y) = x = g - (g-x) ≈ g - tan(g-x)

Since tan is odd function, we expected guess below x also as good.

lua> g = x - 0.001 -- guess
lua> t = tan(g)
lua> g - (t-y)/(1+t*y) -- Halley's method
1.2490457727315878

lua> x - 1.249045772064921, x - 1.2490457727315878
3.33333360913457e-010       -3.33333360913457e-010
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP 17B Solver - another ARCTAN(Y/X) approximation - Albert Chan - 08-19-2021 02:42 AM



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