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

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).

-
Is your goal to locate, say $y = \sin(\frac{\pi}{180})$, on the real number line? To be able to say things like $0.01745 < y < 0.01746$? In that case, the approximation by using enough terms in the Taylor series (Maclaurin series) is great. [cont'd...] –  Sammy Black Aug 5 at 17:42
Halving formula won't give yoou exact values unless you restrict to special rational multiples of $\pi$. –  Jyrki Lahtonen Aug 5 at 17:42
[...cont'd] Or do you want to know exact statements, such as the fact that $x = \cos(\frac{\pi}{5})$ is the positive root of the polynomial $4x^2 - 2x - 1$? These require finding roots of polynomial equations, a daunting (and usually impossible in radicals) task if the degrees are large. –  Sammy Black Aug 5 at 17:45
Finding $\sin(1^\circ)$ involves solving a cubic equation (in the casus irreducibilis), so unless you are content with radicals of complex numbers, you are stuck. –  GEdgar Aug 5 at 17:50
I imagine an equivalent formulation of this question is: "Which angles are constructible via compass and straightedge, and what is the algorithm for constructing those that are?" That would be something else you could search under. –  Semiclassical Aug 5 at 17:57

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}}$$

-
And that's all there is to it. No problemo. –  Tyler Durden Aug 5 at 18:30
@alexqwx haha This is probably the least efficient method, since I wait until the absolute end to do any sort of simplifying. But the theory of simplifying radicals is complex and currently an active area of research (see: Landau's Algorithm) for more information –  frogeyedpeas Aug 5 at 18:43
No. The question there asks for finite sets, but the answer is much more general. In particular, the solution of Hilbert’s sextic conjecture by Abhyankar basically means that solutions to generic degree-6 polynomials cannot be expressed using any family of one-variable algebraic functions (such as your $Q(n,-)$, which you wrote as two-variable, but is really a countable set of one-variable functions indexed by $n$). –  Emil Jeřábek Aug 5 at 19:36
It may be interesting to note that the sine and cosine of $\pi/p$ for $p=3,5,17,257,65537$ are all constructible, and so can be computed with just square roots. –  Hurkyl Aug 5 at 23:17

$$\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})$$

-
Solving that last equation (for $\sin 1^\circ$) (by Cardano to get an exact answer) necessitates calculation of complex cubic roots. Guess what, calculating a complex cubic root necessitates the calculation of cosine/sine of an angle divide by three. HALP! We're in a loop! –  Jyrki Lahtonen Aug 5 at 17:50
when we have 3 root in cubic ,then by Cardano , we could find all roots but when we want to express two of them in well known function we could use $4cos^3(x)-3cos(x)=cos(3x)$ trick. –  mba Aug 5 at 17:55

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.

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.

-
Close but not exact... –  copper.hat Aug 5 at 17:38
This is a scheme to approximate the values. The OP is asking about exact values, no? –  Sammy Black Aug 5 at 17:38
Are you sure that this is how calculators do it? I have always thought that calculators use CORDIC. –  Jyrki Lahtonen Aug 5 at 17:45
From the article you linked, CORDIC is used in computational circuits that don't have hardware multipliers. The Taylor series has lower space requirements (CORDIC requires a table of precomputed values; the T-S can be calculated from scratch) but requires a high-bitcount AU and ideally an FPU to be efficient, both of which are standard equipment on practically every desktop CPU (and then laptop/mobile) manufactured since the mid-90s. –  KeithS Aug 5 at 17:55

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)}$.

-
Quite the opposite, $\cos(m\pi n)$ (and thus $\sin(m\pi/n)$) is always expressible using radicals. Its splitting field is just $\mathbb Q(\zeta_{2n})\cap\mathbb R$, assuming $(n,m)=1$. –  Emil Jeřábek Aug 6 at 12:35
Oops, sorry for that... I removed the statement about radicals. –  Robert Israel Aug 7 at 2:12