HP 17B Solver - another ARCTAN(Y/X) approximation
05-15-2021, 11:01 PM (This post was last modified: 05-16-2021 01:34 AM by Albert Chan.)
Post: #2
 Albert Chan Senior Member Posts: 2,607 Joined: Jul 2018
RE: HP 17B Solver - another ARCTAN(Y/X) approximation
(05-15-2021 09:14 AM)Martin Hepperle Wrote:  I guess there are options to reduce the complexity of the quadrant handling.

Code:
function my_atan2(y, x)     local z, offset, p = y/x, 0, (y >= 0 and pi or -pi)     if abs(z)>1 then z, offset = -x/y, p/2 end     if x < 0 then offset = p - offset end -- Q2, Q3     local s = z*z     z = z * (((15159/35*s + 4213)*s + 9867)*s + 6435) /       ((((35*s + 1260)*s + 6930)*s + 12012)*s + 6435)     return z + offset end

This may be simpler in logic, letting atan() part take care of Q1 and Q4.
Also, returned angles matched most implementation of atan2, -pi < angle ≤ pi

Reference: https://mae.ufl.edu/~uhk/ARCTAN-APPROX-PAPER.pdf

---

What is the reason for 0 = (R-R) + ... ?

Comment: I had matched the top/bottom polynomial constant term.
(so that it is more obvious to see formula gives atan(ε) ≈ ε, as expected)

Coefficient 15159/35 is not an integer, we might as well adjust it to reduce relative error.
Replace 15159/35 by 433.1338, we reduced max. rel error from 1.2e-6, down to 2.9e-7
 « 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: 2 Guest(s)