[VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier"
|
04-05-2019, 07:40 PM
(This post was last modified: 04-07-2019 04:12 PM by Albert Chan.)
Post: #28
|
|||
|
|||
RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier"
Below Lua code scale cin argument to [sin(0.5), 0.5], do cin, then undo asin/sin's
local sin, asin = math.sin, math.asin function cin(x) local y, n = x*x, 0 while y > 0.25 do x=sin(x); y=x*x; n=n+1 end if y < 0.0324 then -- |x| < 0.18 local z = y*(0.00013898 + y*0.00003744) + 13583/29393280 x = x - x*y*(1/18 + y*(7/1080 + y*(643/408240 + y*z))) return n==0 and x or asin(x) end while y < 0.229848847 do x=asin(x); y=x*x; n=n-1 end y = y - 0.2399 -- |x| = [sin(0.5), 0.5] y = 0.013724194890539722 + y*( 0.058965322546572385 + y*( 0.007795773378183463 + y*( 0.002109528417736682 + y*( 0.000663984666232017 + y*( 0.000199482968029459 ))))) x = x - x*y -- x = cin(x) for i=1,n do x = asin(x) end for i=1,-n do x = sin(x) end return x end Result *very* accurate. Example: x = 2.019 cin(x) = 1.02692 331869 35764 cin(cin(x)) = 0.956628 929996 1186 cin(cin(cin(x))) = 0.90122 698939 98129 math.sin(x) = 0.90122 698939 98126 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)