Post Reply 
Question for Trig Gurus
07-29-2022, 03:19 PM (This post was last modified: 07-29-2022 03:56 PM by Albert Chan.)
Post: #22
RE: Question for Trig Gurus
(12-04-2014 02:36 AM)Gerson W. Barbosa Wrote:  
(12-02-2014 07:34 PM)Gerson W. Barbosa Wrote:  For the range 1/2..1, we use simmetry.

This is completely wrong (including spelling), sorry! Desirable accuracy should be granted in the range [0..sqrt(2)/2],
then for the range [sqrt(2)/2..1] we use the formula

asin(x) = 90° - asin(sqrt(1 - x^2))

It is easy to reduce x, from [1/2 .. sqrt(2)/2], to [0 .. 1/2]

cos(2y) = 2*cos(y)^2 - 1
2y = acos(2*cos(y)^2 - 1) = 90° - asin(1 - 2*sin(y)^2)

Let y = asin(x):

asin(x) = 45° - asin(1-2*x^2)/2

---

We can define asinq(x) = asin(sqrt(x))
This allowed simple transformation, using SOHCAHTOA mnemonic, H=O+A

acos(√x) = acosq(x) = asinq(1-x)                   // O, A, H = 1-x, x, 1
atan(√x) = atanq(x) = asinq(x/(1+x))            // O, A, H = x, 1, 1+x

(04-01-2022 05:49 PM)Albert Chan Wrote:  
Code:
function asinq(x)   -- asin(sqrt(x)), x = 0 to 1
    if x > 1/2  then return pi/2 - asinq(1-x) end
    if x > 1/4  then return pi/4 - asinq((1-2*x)^2)/2 end
    if x > 4e-4 then return 2 * asinq(0.5*x/(sqrt(1-x)+1)) end
    return sqrt(x) * (1+x/6*(1+x*9/20/(1-x*25/42)))
end

Example, following above code steps.

acos(0.6)
= asinq(1 - 0.36)
= pi/2 - asinq(0.36)
= pi/2 - (pi/4 - asinq(0.0784)/2)
= pi/4 + 1*asinq(0.02)
= pi/4 + 2*asinq(0.005025253169416733)
= pi/4 + 4*asinq(0.0012578955936787797)
= pi/4 + 8*asinq(0.0003145728545004835)
= pi/4 + 0.1418970546041639
= 0.9272952180016122 -- or, 53.13010235415598°

Comment: code to reduce argument to 1/4 or less can be removed.
Code can rely on "half-angle" reduction formula alone (i.e. without using pi)

acos(0.6)
= 1 * asinq(0.64)
= 2 * asinq(0.2)
= 4 * asinq(0.05278640450004206)
= 8 * asinq(0.013375505266134917)
= 16 * asinq(0.003355133235562103)
= 32 * asinq(0.0008394880490750656)
= 64 * asinq(0.0002099160770281613)
= 0.9272952180016122
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: 1 Guest(s)