Post Reply 
Question for Trig Gurus
08-02-2022, 05:28 PM
Post: #32
RE: Question for Trig Gurus
(12-01-2014 07:49 PM)Namir Wrote:  The machine has trigonometric functions but not their inverse counterpart.

sin(x) = x - 1/6*x^3 + 1/120*x^5 - 1/5040*x^7 + ...
asin(x) = x + 1/6*x^3 + 3/40*x^5 + 5/112*x^7 + ...

(sin(x)*asin(x))/x^2 = 1 + x^4/18 + x^6/30 + ...

RHS x^2 term get cancelled, as expected; this made RHS ≈ 1
We flip LHS, because then ... terms get smaller in size.

x^2/(sin(x)*asin(x)) = 1 - x^4/18 - x^6/30 - ... ≈ 1 - x^4/18 / (1 - 3/5*x^2)

asin(x) ≈ (x^2)/sin(x) / (1 - x^4/(18 - (k = 10.8) * x^2))

Above formula, we have deg(asin(1/2)) ≈ 29.999857.
If we limit x within ±1/2, we already have 5+ digits accuracy.

If we back solve for k, for asin(1/2) = pi/6, we have k = 10.8709
For x within ±1/2, we can get 6+ digits accuracy, if we pick k = 10.87

If we don't have sin function, 4 terms are needed, for 6 digits accuracy.
To save computations, we use 3 terms: sin(x) ≈ x - x^3/3! + x^5/5!

k is adjusted to compensate, to still maintain 6+ digits accuracy.
Trial and errors gives k = 10.914

\( \arcsin(x)
≈ \Large \frac{x} {
\left(1 - \frac{x^2}{6} \left(1 - \frac{x^2}{20}\right) \right)
\;×\; \left(1 - \frac{x^4}{18\;-\;10.914\;x^2}\right)
}\)

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 = (1-z/6*(1-z/20)) * (1-z*z/(18-z*10.914))
    return deg(x/z)
end

acosd(x) result, using above asind(x)

0.0: 90.000000 (90.000000)
0.1: 84.260830 (84.260830)
0.2: 78.463041 (78.463041)
0.3: 72.542395 (72.542397)
0.4: 66.421813 (66.421822)
0.5: 60.000010 (60.000000)
0.6: 53.130103 (53.130102)
0.7: 45.572996 (45.572996)
0.8: 36.869897 (36.869898)
0.9: 25.841944 (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: 2 Guest(s)