Post Reply 
Question for Trig Gurus
08-01-2022, 02:36 PM (This post was last modified: 08-02-2022 10:35 AM by Albert Chan.)
Post: #30
RE: Question for Trig Gurus
Hi, Thomas Klemm

Thanks for clearing this up.

d(3,3) were used for 5+ digits accuracy, because there is no argument reduction.
Here is a version that use simpler d(2,2), but reduce asind() argument to 0 .. 1/2

a0=√(1-x²) , g0=1, a1=(g0+a0)/2, g1=√(a1*g0)

45 a ≈ a0 - 20*a1 + 64*a2 = a0 + 12*a1 + 32*g1

Code:
function asind(s,c) -- deg(asin(s)), 6+ digits accuracy
    c = c or sqrt(1-s*s)
    if s < 0   then return -asind(-s,c) end
    if s > c   then return 90 - asind(c,s) end
    if s > 0.5 then return 45 - asind(1-2*s*s)/2 end
    c = 6 + 7*c + sqrt(512*(1+c))
    return deg(45*s/c)
end

function acosd(x) return 90 - asind(x) end
function atand(x) return asind(x/hypot(1,x)) end

lua> for i=0,10 do x=i/10; printf('%.1f: %.6f (%.6f)\n', x, acosd(x), deg(acos(x))) end

0.0: 90.000000 (90.000000)
0.1: 84.260830 (84.260830)
0.2: 78.463041 (78.463041)
0.3: 72.542396 (72.542397)
0.4: 66.421818 (66.421822)
0.5: 59.999979 (60.000000)
0.6: 53.130102 (53.130102)
0.7: 45.572996 (45.572996)
0.8: 36.869898 (36.869898)
0.9: 25.841940 (25.841933)
1.0: 0.000000   (0.000000)

Update: Here is pade(asin(x),x,10,6) version

Code:
function asind(x) -- deg(asin(s)), 6+ digits accuracy
    if x < 0   then return -asind(-x) end
    local z = x*x
    if z > 0.5 then return 90 - asind(sqrt(1-z)) end
    if x > 0.5 then return 45 - asind(1-2*z)/2 end
    z = z*(5490-z*2717)/(32940-z*(31125-z*145125/28))
    return deg(x + x*z)
end

acosd(x) results, using Pade version asind(x)

0.0: 90.000000 (90.000000)
0.1: 84.260830 (84.260830)
0.2: 78.463041 (78.463041)
0.3: 72.542397 (72.542397)
0.4: 66.421824 (66.421822)
0.5: 60.000037 (60.000000)
0.6: 53.130102 (53.130102)
0.7: 45.572996 (45.572996)
0.8: 36.869898 (36.869898)
0.9: 25.841926 (25.841933)
1.0: 0.000000   (0.000000)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Question for Trig Gurus - Namir - 12-01-2014, 07:49 PM
RE: Question for Trig Gurus - toml_12953 - 12-01-2014, 08:08 PM
RE: Question for Trig Gurus - PANAMATIK - 12-01-2014, 08:46 PM
RE: Question for Trig Gurus - Namir - 12-01-2014, 10:54 PM
RE: Question for Trig Gurus - toml_12953 - 12-02-2014, 02:30 AM
RE: Question for Trig Gurus - Namir - 12-02-2014, 09:21 AM
RE: Question for Trig Gurus - Namir - 12-02-2014, 04:57 PM
RE: Question for Trig Gurus - Albert Chan - 07-29-2022, 03:19 PM
RE: Question for Trig Gurus - Mark Hardman - 12-01-2014, 11:00 PM
RE: Question for Trig Gurus - Thomas Klemm - 12-02-2014, 12:09 AM
RE: Question for Trig Gurus - Namir - 12-02-2014, 12:16 AM
RE: Question for Trig Gurus - Thomas Klemm - 12-02-2014, 01:12 AM
RE: Question for Trig Gurus - Namir - 12-02-2014, 01:50 AM
RE: Question for Trig Gurus - Namir - 12-02-2014, 01:49 AM
RE: Question for Trig Gurus - Namir - 12-05-2014, 02:48 AM
RE: Question for Trig Gurus - Namir - 12-09-2014, 02:19 PM
RE: Question for Trig Gurus - Thomas Klemm - 07-29-2022, 12:59 PM
RE: Question for Trig Gurus - ttw - 07-29-2022, 10:19 PM
RE: Question for Trig Gurus - Thomas Klemm - 07-30-2022, 08:26 AM
RE: Question for Trig Gurus - Albert Chan - 07-30-2022, 06:27 PM
RE: Question for Trig Gurus - Thomas Klemm - 07-30-2022, 09:38 AM
RE: Question for Trig Gurus - Thomas Klemm - 07-31-2022, 11:08 AM
RE: Question for Trig Gurus - Albert Chan - 07-31-2022, 09:54 PM
RE: Question for Trig Gurus - Thomas Klemm - 08-01-2022, 05:19 AM
RE: Question for Trig Gurus - Albert Chan - 08-01-2022 02:36 PM
RE: Question for Trig Gurus - Thomas Klemm - 08-02-2022, 06:35 AM
RE: Question for Trig Gurus - Albert Chan - 08-02-2022, 05:28 PM
RE: Question for Trig Gurus - Thomas Klemm - 08-03-2022, 04:42 PM



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