[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Fun math puzzle: cin(X)
- From: Albert Chan <albertmcchan@...>
- Date: Thu, 4 Apr 2019 22:06:48 -0400
This is my cin(x) version, by reducing |x| to below 0.1 radian.
If |x| >= 0.1, it's reduced value = (sin(0.1) to 0.1) ~ (0.099833, 0.1)
Taylor series last term is adjusted to reduce errors for this tight domain.
local abs, sin, asin = math.abs, math.sin, math.asin
function cin(x)
local n = 0 -- count nested sin's
while abs(x) >= 0.1 do x=sin(x); n=n+1 end
local x2 = x*x
x = x - x*x2*(1/18 + x2*(7/1080 + x2*(643/408240 + x2*0.0004635)))
for i=1,n do x=asin(x) end
return x
end
Result has about 13 digits accuracy:
x = 2.019
cin(x) = 1.02692 331869 35365
cin(cin(x)) = 0.95662 892999 61478
cin(cin(cin(x))) = 0.90122 698939 98782
math.sin(x) = 0.90122 698939 98126