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 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) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)