HP Forums
Odd Angles Formula Trivia - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: Odd Angles Formula Trivia (/thread-11992.html)



Odd Angles Formula Trivia - Albert Chan - 12-20-2018 05:38 PM

Reading Multiple Angle Formulas, noticed some pattern for odd angles

Let s = sin(x), c = cos(x):

sin(-x) = -s
cos(-x) = c
sin(x) = s
cos(x) = c

sin(3 x) = -(4 s³ - 3 s)
cos(3 x) = 4 c³ - 3c
sin(5 x) = 16 s5 - 20 s³ + 5 s
cos(5 x) = 16 c5 - 20 c³ + 5 c

Challenge: prove above pattern continues: if sin(4nx ± x) = f(s,c), then cos(4nx ± x) = ± f(c,s)


RE: Odd Angles Formula Trivia - Albert Chan - 12-21-2018 01:10 PM

(12-20-2018 05:38 PM)Albert Chan Wrote:  Challenge: prove above pattern continues: if sin(4nx ± x) = f(s,c), then cos(4nx ± x) = ± f(c,s)

Let angle A = 4kx + x, s = sin(x), c = cos(x):

sin(A+2x) = sin(A) cos(2x) + cos(A) sin(2x) = f(s,c) (c² - s²) + f(c,s) (2 s c) = g(s,c)
cos(A+2x) = cos(A) cos(2x) - sin(A) sin(2x) = f(c,s) (c² - s²) - f(s,c) (2 s c) = -g(c,s)

sin(A+4x) = sin(A+2x) cos(2x) + cos(A+2x) sin(2x) = g(s,c) (c² - s²) - g(c,s) (2 s c) = h(s,c)
cos(A+4x) = cos(A+2x) cos(2x) - sin(A+2x) sin(2x) = -g(c,s) (c² - s²) - g(s,c) (2 s c) = h(c,s)

Angles A+2x and A+4x is same as 4(k+1)x ± x
Post #1 examples already shows n=1 work, and by induction, if n=k work, n=k+1 also work.

QED


RE: Odd Angles Formula Trivia - Albert Chan - 08-14-2019 01:54 PM

We can show above sign flipping behavior, using Chebyshev Polynomial

By definition, Tn(cos(x)) = cos(n*x)

Tn(cos(pi/2-x)) = cos(n*(pi/2-x)) = cos((n-1)*pi/2 + (pi/2-n*x))
Tn(sin(x)) = sin(n*x + (n-1)*pi/2)

if n=4k+1, (n-1)*pi/2 ≡ 0 (mod 2*pi), then Tn(sin(x)) = sin(n*x+0) = sin(n*x)
if n=4k−1, (n-1)*pi/2 ≡ pi (mod 2*pi), then Tn(sin(x)) = sin(n*x+pi) = - sin(n*x)

QED

Extend above for even n's:

if n=4k+0, n*pi/2 ≡ 0 (mod 2*pi), then Tn(sin(x)) = cos(0-n*x) = cos(n*x)
if n=4k+2, n*pi/2 ≡ pi (mod 2*pi), then Tn(sin(x)) = cos(pi-n*x) = - cos(n*x)


RE: Odd Angles Formula Trivia - Albert Chan - 08-15-2019 01:55 AM

Numerically, it is better not to use multiple angle formula for cos(n*x)
When x is small, cos(x) approach 1.0, and might "pushed away" many significant digits.

Example, using HP-12C, calculate cos(1), by applying T5 3 times

T5(x) = 5x - 20x^3 + 16x^5 = x(5 - x²(20 - x²(16)))
x = 1/5³ = 0.008 // reduced angle, in radian

cos(x) ≅ 1 - x^2/2 + x^4/24 = 1 - 0.00003199982933 = 0.9999680002
cos(0.04) = 0.9992001048, error = 19 ULP
cos(0.20) = 0.9800665309, error = 469 ULP
cos(1.00) = 0.5403013120, error = 9939 ULP

Had we use sin(5x) formula (same T5, but start with sin(x)):

sin(x) ≅ x - x^3/6 = 0.007999914667
sin(0.04) = 0.03998933419, error = 0 ULP
sin(0.20) = 0.1986693308,   error = 0 ULP
sin(1.00) = 0.8414709849,   error = -1 ULP

cos(1) = √(1 - sin(1)²) = 0.5403023058, error = 1 ULP
Actual value for cos(1) = 0.54030 23058 68139 ...

note: error (under-estimated) = exact - approx


RE: Odd Angles Formula Trivia - Albert Chan - 08-15-2019 03:42 PM

(08-15-2019 01:55 AM)Albert Chan Wrote:  x = 1/5³ = 0.008 // reduced angle, in radian

cos(x) ≅ 1 - x^2/2 + x^4/24 = 1 - 0.00003199982933 = 0.9999680002
cos(0.04) = 0.9992001048, error = 19 ULP
cos(0.20) = 0.9800665309, error = 469 ULP
cos(1.00) = 0.5403013120, error = 9939 ULP

A trick to improve accuracy, by defining cosm1(x) = cos(x) - 1

Polynomial to scale cosm1(x) to cosm1(5x)
= T5(x+1) - 1
= 25x + 100x^2 + 140x^3 + 80x^4 + 16x^5
= ((4*x + 10)*x + 5)^2 * x

cosm1(x) ≅ -x^2/2 + x^4/24 = -0.00003199982933
cosm1(0.04) = -0.0007998933389, error = -1 ULP
cosm1(0.20) = -0.01993342215, error = -1 ULP
cosm1(1.00) = -0.4596976940, error = -1 ULP

cos(1) = cosm1(1) + 1 = 0.5403023060, error = -1 ULP


RE: Odd Angles Formula Trivia - Albert Chan - 12-15-2019 01:03 AM

A trick to convert cos(x)n as linear combinations of multiple angle cos

Example: cos(x)³ to linear combinations of cos(3x) and cos(x)

Let complex number z = exp(i x)

(z + 1/z) = 2 cos(x)
(z + 1/z)³ = z³ + 3z + 3/z + 1/z³ = (z³ + 1/z³) + 3(z + 1/z)

Divide above (both side) by 2, we get: 2² cos(x)³ = cos(3x) + 3 cos(x)

We can skip above steps, and write formula directly !
Example: 6th row of pascal triangle = 1 6 15 20 15 6 1

25 cos(x)6 = cos(6x) + 6 cos(4x) + 15 cos(2x) + 20/2


RE: Odd Angles Formula Trivia - Albert Chan - 12-15-2019 01:49 AM

The same trick work for sin(x)n, but only odd n can convert to multiple angle sin

Example, for sin(x)³:

(z - 1/z) = 2i sin(x)
(z - 1/z)³ = z³ - 3z + 3/z - 1/z³ = (z³ - 1/z³) - 3(z - 1/z)

Divide above (both side) by -2i, we get: 2² sin(x)³ = -sin(3x) + 3 sin(x)

For even n, we get back linear combinations of multiple angles cos:

(z - 1/z)6 = z6 - 6z4 + 15z² - 20 + 15/z² - 6/z4 + 1/z6 = (z6 + 1/z6) - 6(z4 + 1/z4) + 15(z² + 1/z²) - 20

Divide above (both side) by -2, we get: 25 sin(x)6 = -cos(6x) + 6 cos(4x) - 15 cos(2x) + 20/2

Update: we can deduce the signs without z's. From right to left, sign pattern is + − + − + − ...


RE: Odd Angles Formula Trivia - Albert Chan - 01-22-2020 12:45 AM

(12-15-2019 01:49 AM)Albert Chan Wrote:  25 sin(x)6 = -cos(6x) + 6 cos(4x) - 15 cos(2x) + 20/2

Since even powers of sines expanded to sum of cosines + constant, we have:
Quote:\(\large \int _{-\pi \over 2} ^{\pi \over 2} (\sin x)^{2n} \;dx = \binom{2n}{n}\pi / 2^{2n} \)

Example, for perimeter of ellipse, where h = (a-b)/(a+b)

\(p = (a+b) \int _{-\pi \over 2} ^{\pi \over 2} \sqrt{(1 + h^2)+ 2h \sin x} \;dx \)

Let \(y={h \over 1+h^2}\;, z = 2y \sin x\), and expand the integrand:

\(\sqrt{1 + h^2 + 2h \sin x} = \sqrt{(1+h^2)(1+z)} = \sqrt{1+h^2} \left[1 +
\binom{½}{1}z + \binom{½}{2}z^2 + \binom{½}{3}z^3 + \binom{½}{4}z^4
+ \binom{½}{5}z^5 + \binom{½}{6}z^6 +\;...\right ]\)

We can remove odd powers of z, since the area cancelled out.
Applying even powers of sine integral formula, we have:

\(p = \pi (a+b) \sqrt{1+h^2} \left[1 + \binom{½}{2}\binom{2}{1}y^2
+ \binom{½}{4}\binom{4}{2}y^4 + \binom{½}{6}\binom{6}{3}y^6 +\; ... \right]
= 2 \pi \sqrt{{a^2+b^2 \over 2}} \left[ 1 - {1\over 4}y^2 - {15\over 64}y^4
- {105 \over 256} y^6 -\; ... \right] \)

Unfortunately, convergence is much slower than series expansion on h.
However, we just proved \( p ≤ 2 \pi \sqrt{{a^2+b^2 \over 2}} \) Smile

For a rough estimate, we can use Trapezoid's rule (2 trapezoids).

\( p ≈ \pi (a+b) \left({(1-h)\;+\; 2\sqrt{1+h^2}\;+\;(1+h) \over 4}\;\right)
= \pi (a + b) \left({1 + \sqrt{1+h^2} \over 2}\;\right)
= \pi \large\left( {a+b \over 2} + \sqrt{{a^2+b^2 \over 2}}
\;\right)\)