What is the most efficient way to calculate the sine of a rational number?

2.3k Views Asked by At

I'm happy that we can use some trig identities like $$\sin\left(\frac{\theta}{2}\right) \equiv \pm \sqrt{\frac{1-\cos(\theta)}{2}}$$ and $$\sin(\alpha \pm\beta) \equiv \sin(\alpha) \cos(\beta)\pm \cos(\alpha)\sin(\beta)$$ (and many more) to calculate exactly, for example, $\sin(15^\circ)=\sin\left(\frac{30^\circ}{2}\right)$ and $\sin(75^\circ)=\sin(90^\circ-15^\circ)$, but it seems that the smaller the angle of which I want to find the sine, the more identities I have to use, so, to calculate, for example, $\sin(1^\circ)$, is very fiddly and tedious.

My question is:

What is the most efficient way to calculate the sine of any rational angle (in as few steps as possible)?

Is there some algorithm for doing this?


P.S. I'm aware of this, which gives $\sin(\theta)$ for $\theta \in[0^\circ,90^\circ] \cap \mathbb{Z}$, but I'd like to be able to calculate, for example, $\sin\left(\frac1{12}\right)$ (exactly).

4

There are 4 best solutions below

12
On BEST ANSWER

Exact answers may not have closed forms for sufficiently small angles but the general method is as follows

Say we know the exact answer to $\sin(u)$ and now want to calculate $\sin(\frac{u}{k})$

For an integer $k$

$$\sin(k\theta)$$

In general by using the rule derived from the angle sum formula:

http://en.wikipedia.org/wiki/Product-to-sum_identities#Sine.2C_cosine.2C_and_tangent_of_multiple_angles

One can expand this out into a large sum of sines and cosines

Now for each of the cosines one can substitute

$$\cos(x) = \sqrt{1 - \sin(x)^2}$$

To get an expression of the form

$$\sin(k \theta) = SOME \ HAIRY \ ALGEBRAIC \ MESS \ FOR \ SUFFICIENTLY \ LARGE \ K$$

Nevertheless we can now "solve" our equation above for $\sin(\theta)$ which allows us to expressed

$$\sin(\theta) = F(\sin(k\theta))$$

Where F is the, generally more complex inverse to the algebraic expression earlier.

Now substitute $u = k \theta, \rightarrow \theta = \frac{u}{k}$

And you've got yourself a formula for integer divisions of angles

So you can actually get exact formulas for ANY and ALL Rational Numbers.

There is one slight crux to this all. The answers can no longer be expressed in radicals when consider rational numbers whose denominators are a multiple of a prime greater than or equal to 5 because in order to express such rational numbers one EVENTUALLY is forced to solve a polynomial of degree 5 or greater (in the attempt to invert the $\sin(x)$ expression) and in general this is not solvable.

But at least you can always get an exact algebraic answer if you extend your set of tools to include ultra-radicals

To see a worked example: consider

$$\sin(2x) = 2\sin(x)\cos(x)$$

(I am cheating and using a prepared identity instead of attempting to trudge through with the angle sum identity, i assure you both methods work)

now some algebraic hocus-pocus

$$\sin(2x) = 2 \sin(x)\sqrt{1 - \sin(x)^2}$$ $$\sin(2x)^2 = 4 \sin(x)^2 (1 - \sin(x)^2)$$ $$4\sin(x)^4 - 4\sin(x)^2 + \sin(2x)^2 = 0$$

And then we bring out the big gunz... meaning the Quadratic Formula (I'll grab the positive have for now although both choices are valid)

$$\sin(x)^2 = \frac{4 + \sqrt{16 - 16\sin(2x)^2}}{8}$$ $$\sin(x) = \sqrt{\frac{1 \pm \sqrt{1 - \sin(2x)^2}}{2}}$$

Meaning

$$\sin(\frac{x}{2}) = \sqrt{\frac{1 \pm \sqrt{1 - \sin(x)^2}}{2}}$$

Course we can get even fancier by looking at something along the lines of

$$\sin \left(\frac{x}{4} \right) = \sqrt{\frac{1 \pm \sqrt{1 - {\frac{1 \pm \sqrt{1 - \sin(x)^2}}{2}}}}{2}} $$

etc... the possibilities are endless. Once you determine

$$\sin(\frac{x}{prime})$$

the multiples of that prime all become accessible (assuming you know the other prime factors as well)

To subdivide by 3 it seems:

$$\sin\left( \frac{x}{3} \right) = \frac{1}{2} \left( \sqrt[3]{\sqrt{\sin(x)^2 - 1} - \sin(x)} + \frac{1}{\sqrt[3]{\sqrt{\sin(x)^2 - 1} - \sin(x)}} \right) $$

so combining my earlier formula with this one:

$$ \sin \left( \frac{x}{12} \right) = \sqrt{\frac{1 \pm \sqrt{1 - {\frac{1 \pm \sqrt{1 - \left(\frac{1}{2} \left( \sqrt[3]{\sqrt{\sin(x)^2 - 1} - \sin(x)} + \frac{1}{\sqrt[3]{\sqrt{\sin(x)^2 - 1} - \sin(x)}} \right) \right)^2}}{2}}}}{2}} $$

2
On

$$\cos(54)=\sin(36) $$

$$\cos(54)=\cos(3\times 18)=4\cos^3(18)-3\cos(18)$$ $$\sin(36)=\sin(2\times 18)=2\sin(18)\cos(18)$$

so $$2\sin(18)=4\cos^2(18)-3$$ now simple calculation shows that $$\sin(18)=\frac{\sqrt{5}-1}{4}$$ so $$\sin(3)=\sin(18-15)=\sin(18)\cos(15)-\cos(18)\sin(15)$$

$\sin(1)$ will be the root of :

$$3\sin(1)-4\sin^3(1)=\sin(3)$$

but solution of the above gives a value involved with too many radicals and complex numbers $i=\sqrt{-1}$ such that it's actually efficient part is real part , it means imaginary part is zero .

for calculating $\sin(\frac{1}{12})$ it sufficent to calculate $\sin (\frac{1}{2})$ then $\sin (\frac{1}{4})$. and calculate $\sin (\frac{1}{3})$ by $3\sin(\frac{1}{3})-4\sin^3(\frac{1}{3})=\sin(1)$ and then $$\sin(\frac{1}{12})=\sin(\frac{1}{3}-\frac{1}{4})$$

4
On

The most computationally-simple method I can think of is the Taylor series. This is how computers do it:

$$\sin(x) = \sum^{\infty}_{n=1} \dfrac{x^{2n-1}}{(2n-1)!} = x + \dfrac{x^3}{3!}+ \dfrac{x^5}{5!}+ \dfrac{x^7}{7!}+ \dfrac{x^9}{9!}+ \dfrac{x^{11}}{11!} +\ ...$$

Plug in a few sample $x$ and $n$ values, and you'll see that the factorial term in the denominator comes to dominate, trending progressively higher terms toward zero and thus the sum toward a definite value. So eventually, you get "close enough" with a finite number of terms of the series. This series is pretty simple to generate; keep a total, the value of the last term generated and the number N of the last factorial in the denominator, then to generate the next term, multiply the previous term by X and divide by N(N-1).

As far as "exactly", well, you can keep going on pencil and paper as long as you want, but there are a lot of common irrational sines; $sin(\dfrac{\pi}{4}) = \dfrac{1}{\sqrt{2}}$, for instance. From a practical and pragmatic standpoint, sooner or later you stop after you have enough sig figs for a real-world calculation.

2
On

For positive integers $m$ and $n$, $(-1)^m = \cos(m \pi) = T_n(\cos(m \pi/n))$, where $T_n$ is the $n$'th Chebyshev polynomial of the first kind. So $\cos(m \pi/n)$ is one of the roots of the polynomial $T_n(z) - (-1)^m$, and of course $\sin(m \pi/n) = \pm \sqrt{1 - \cos^2(m \pi/n)}$.