Trig algorithms on HP RPN?
|
12-01-2024, 07:27 PM
(This post was last modified: 12-01-2024 08:46 PM by Albert Chan.)
Post: #6
|
|||
|
|||
RE: Trig algorithms on HP RPN?
(11-30-2024 03:49 PM)Thomas Klemm Wrote: Should last digit for pi/4 a 4? lua> pi/4 0.7853981633974483 (11-30-2024 03:49 PM)Thomas Klemm Wrote: Honestly, I don't know why that wasn't used instead. Just a guess, if angles are in radian, we can just use tan code to get atan tan sum formula: tan(x+y) = (tan(x) + tan(y)) / (1 - tan(x)*tan(y)) Flip for atan: atan(x) = atan( y + (x-y) ) atan(x) = atan(y) + atan(z), where z = (x-y)/(1+x*y) if y = tan(x), (x-y) ≈ x^3/3 --> z shrink fast, cubic convergence! But we can do better! y can be set to anything. As long as y is close to x, z will shrink fast. Below, y = tan(x2 = x/(1+x*x/3)), to get convergence rate of O(x^5) Code: function myatan(x, s) lua> myatan(0.1) 0 + atan( 0.1 ) 0.09966777408637874 + atan( 8.784047832967151e-07 ) 0.09966865249116204 + atan( -1.0587911840670585e-22 ) 0.09966865249116204 lua> myatan(1) 0 + atan( 1 ) 0.75 + atan( 0.03541295579818369 ) 0.7853981584542247 + atan( 4.943223638603625e-09 ) 0.7853981633974483 |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Trig algorithms on HP RPN? - MinkLib - 11-30-2024, 01:39 PM
RE: Trig algorithms on HP RPN? - Idnarn - 11-30-2024, 02:09 PM
RE: Trig algorithms on HP RPN? - naddy - 11-30-2024, 03:15 PM
RE: Trig algorithms on HP RPN? - Thomas Klemm - 11-30-2024, 03:49 PM
RE: Trig algorithms on HP RPN? - Gerson W. Barbosa - 12-01-2024, 05:17 PM
RE: Trig algorithms on HP RPN? - Albert Chan - 12-01-2024 07:27 PM
RE: Trig algorithms on HP RPN? - Albert Chan - 12-01-2024, 07:30 PM
RE: Trig algorithms on HP RPN? - Gerson W. Barbosa - 12-02-2024, 08:59 PM
RE: Trig algorithms on HP RPN? - Thomas Klemm - 12-01-2024, 07:47 PM
RE: Trig algorithms on HP RPN? - Thomas Klemm - 12-01-2024, 08:13 PM
|
User(s) browsing this thread: 4 Guest(s)