HP 17B Solver - another ARCTAN(Y/X) approximation
|
05-31-2021, 09:51 PM
(This post was last modified: 06-12-2021 03:10 PM by Albert Chan.)
Post: #10
|
|||
|
|||
RE: HP 17B Solver - another ARCTAN(Y/X) approximation
(05-31-2021 04:42 PM)Albert Chan Wrote: \(\displaystyle\arctan(x) = 2\arctan\left( {x \over \sqrt{2\sqrt{1+x^2}+x^2+2}} \right)\) There is no need to use RC formulas to solve for h, for atan(x) = 2*atan(h) Let h = tan(θ), |θ| ≤ pi/4 2*θ = atan(tan(2*θ)) 2*atan(h) = atan(2*h/(1-h*h)) = atan(x) 2*h/(1-h*h) = x x*h^2 + 2*h - x = 0 Remove quadratic solution of wrong sign (h and x sign should match), we have: h = (√(1+x²)-1) / x = x / (√(1+x²)+1) This h is same as above quoted formula, only simpler \(\displaystyle\arctan(x) = 2\arctan\left( {x \over \sqrt{1+x^2}+1} \right)\) Code: from math import sqrt >>> myatan(1) 0.78539816339744839 >>> myatan(.5) 0.46364760900080615 >>> myatan(10) # |atan(x) = 2θ| ≤ pi/2 1.4711276743037345 >>> myatan(100) 1.5607966601082317 Update: Thomas Kleem beats me to it 2 years ago https://www.hpmuseum.org/forum/thread-12...#pid113694 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)