HP 17B Solver - another ARCTAN(Y/X) approximation
05-31-2021, 07:30 PM
Post: #9
 Albert Chan Senior Member Posts: 2,556 Joined: Jul 2018
RE: HP 17B Solver - another ARCTAN(Y/X) approximation
For comparison, this is asin half-"angle" formula (we derive this the same way as atan):

$$\displaystyle\arcsin(x) = 2\arcsin\left( {x \over \sqrt{2\sqrt{1-x^2}+2}} \right)$$

RC(1-y,1) = asin(√y)/(√y) = 1 + y/6 + 3/40*y² + 5/112*y³ + 35/1152*y4 + ...

Code:
from math import sqrt def myasin(x, verbal=False):     y = x*x             # asin(x) = x*RC(1-y,1)     while y > 1e-3:     # = 2*x*RC(k-y,k) = 2/sqrt(k)*x * RC(1-y/k,1)         k = 2*(sqrt(1-y)+1)         x *= 2/sqrt(k)         y /= k         if verbal: k=sqrt(y); print x/k,'* asin(',k,')'     return x + x*y*(1/6 + y*(3/40 + y*(5/112 + y*(35/1152))))

Redo atan(1.), atan(.5) examples:

>>> x = 1.
>>> myasin(x/sqrt(1+x*x), verbal=1)
2.0 * asin( 0.382683432365 )
4.0 * asin( 0.195090322016 )
8.0 * asin( 0.0980171403296 )
16.0 * asin( 0.0490676743274 )
32.0 * asin( 0.0245412285229 )
0.78539816339744828

>>> x = .5
>>> myasin(x/sqrt(1+x*x), verbal=1)
2.0 * asin( 0.229752920547 )
4.0 * asin( 0.115652519498 )
8.0 * asin( 0.0579235119409 )
16.0 * asin( 0.0289739201537 )
0.46364760900080609
 « Next Oldest | Next Newest »

 Messages In This Thread HP 17B Solver - another ARCTAN(Y/X) approximation - Martin Hepperle - 05-15-2021, 09:14 AM RE: HP 17B Solver - another ARCTAN(Y/X) approximation - Albert Chan - 05-15-2021, 11:01 PM RE: HP 17B Solver - another ARCTAN(Y/X) approximation - Martin Hepperle - 05-16-2021, 08:42 AM RE: HP 17B Solver - another ARCTAN(Y/X) approximation - Albert Chan - 05-16-2021, 01:03 PM RE: HP 17B Solver - another ARCTAN(Y/X) approximation - Albert Chan - 05-16-2021, 05:04 PM RE: HP 17B Solver - another ARCTAN(Y/X) approximation - Albert Chan - 05-17-2021, 12:43 PM RE: HP 17B Solver - another ARCTAN(Y/X) approximation - Albert Chan - 05-31-2021, 04:42 PM RE: HP 17B Solver - another ARCTAN(Y/X) approximation - Albert Chan - 05-31-2021 07:30 PM RE: HP 17B Solver - another ARCTAN(Y/X) approximation - Albert Chan - 05-31-2021, 09:51 PM RE: HP 17B Solver - another ARCTAN(Y/X) approximation - Martin Hepperle - 06-01-2021, 03:16 PM RE: HP 17B Solver - another ARCTAN(Y/X) approximation - Albert Chan - 06-01-2021, 04:38 PM RE: HP 17B Solver - another ARCTAN(Y/X) approximation - Albert Chan - 08-29-2021, 11:39 PM RE: HP 17B Solver - another ARCTAN(Y/X) approximation - Albert Chan - 05-17-2021, 06:01 PM 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)