Sine and cosine

In mathematics, sine and cosine are trigonometric functions of an angle. The sine and cosine of an acute angle are defined in the context of a right triangle: for the specified angle, its sine is the ratio of the length of the side that is opposite that angle to the length of the longest side of the triangle (the hypotenuse), and the cosine is the ratio of the length of the adjacent leg to that of the hypotenuse. For an angle $$\theta$$, the sine and cosine functions are denoted as $$\sin \theta$$ and $$\cos \theta$$.

The definitions of sine and cosine have been extended to any real value in terms of the lengths of certain line segments in a unit circle. More modern definitions express the sine and cosine as infinite series, or as the solutions of certain differential equations, allowing their extension to arbitrary positive and negative values and even to complex numbers.

The sine and cosine functions are commonly used to model periodic phenomena such as sound and light waves, the position and velocity of harmonic oscillators, sunlight intensity and day length, and average temperature variations throughout the year. They can be traced to the jyā and koṭi-jyā functions used in Indian astronomy during the Gupta period.

Notation
Sine and cosine are written using functional notation with the abbreviations sin and cos.

Often, if the argument is simple enough, the function value will be written without parentheses, as $sin θ$ rather than as $sin(θ)$.

Each of sine and cosine is a function of an angle, which is usually expressed in terms of radians or degrees. Except where explicitly stated otherwise, this article assumes that the angle is measured in radians.

Right-angled triangle definitions


To define the sine and cosine of an acute angle α, start with a right triangle that contains an angle of measure α; in the accompanying figure, angle α in triangle ABC is the angle of interest. The three sides of the triangle are named as follows:


 * The opposite side is the side opposite to the angle of interest, in this case side a.
 * The hypotenuse is the side opposite the right angle, in this case side h. The hypotenuse is always the longest side of a right-angled triangle.
 * The adjacent side is the remaining side, in this case side b. It forms a side of (and is adjacent to) both the angle of interest (angle A) and the right angle.

Once such a triangle is chosen, the sine of the angle is equal to the length of the opposite side, divided by the length of the hypotenuse:


 * $$\sin(\alpha) = \frac {\textrm{opposite}} {\textrm{hypotenuse}}\qquad\cos(\alpha) = \frac {\textrm{adjacent}} {\textrm{hypotenuse}}$$

The other trigonometric functions of the angle can be defined similarly; for example, the tangent is the ratio between the opposite and adjacent sides.

As stated, the values $$\sin(\alpha)$$ and $$\cos(\alpha)$$ appear to depend on the choice of right triangle containing an angle of measure α. However, this is not the case: all such triangles are similar, and so the ratios are the same for each of them.

Unit circle definitions
In trigonometry, a unit circle is the circle of radius one centered at the origin (0, 0) in the Cartesian coordinate system.

Let a line through the origin intersect the unit circle, making an angle of θ with the positive half of the x-axis. The x- and y-coordinates of this point of intersection are equal to $cos(θ)$ and $sin(θ)$, respectively. This definition is consistent with the right-angled triangle definition of sine and cosine when $$0 < \theta < \frac{\pi}{2}$$: because the length of the hypotenuse of the unit circle is always 1, $$\sin(\theta) = \frac {\text{opposite}} {\text{hypotenuse}} = \frac {\text{opposite}} {1} = {\text{opposite}}$$. The length of the opposite side of the triangle is simply the y-coordinate. A similar argument can be made for the cosine function to show that $$\cos (\theta) = \frac {\text{adjacent}}{\text{hypotenuse}}$$ when $$0 < \theta < \frac{\pi}{2}$$, even under the new definition using the unit circle. $tan(θ)$ is then defined as $$\frac{\sin(\theta)}{\cos(\theta)}$$, or, equivalently, as the slope of the line segment.

Using the unit circle definition has the advantage that the angle can be extended to any real argument. This can also be achieved by requiring certain symmetries, and that sine be a periodic function.

Complex exponential function definitions
The exponential function $$e^z$$ is defined on the entire domain of the complex numbers. The definition of sine and cosine can be extended to all complex numbers via
 * $$\sin z = \frac{e^{iz} - e^{-iz}}{2i}$$
 * $$\cos z = \frac{e^{iz} + e^{-iz}}{2}$$

These can be reversed to give Euler's formula
 * $$e^{iz} = \cos z + i \sin z$$
 * $$e^{-iz} = \cos z - i \sin z$$

When plotted on the complex plane, the function $$e^{ix}$$ for real values of $$x$$ traces out the unit circle in the complex plane.

When $$x$$ is a real number, sine and cosine simplify to the imaginary and real parts of $$e^{ix}$$ or $$e^{-ix}$$, as:
 * $$\sin x = \operatorname{Im}(e^{ix}) = -\operatorname{Im}(e^{-ix})$$
 * $$\cos x = \operatorname{Re}(e^{ix}) = \operatorname{Re}(e^{-ix})$$

When $$z=x+iy$$ for real values $$x$$ and $$y$$, sine and cosine can be expressed in terms of real sines, cosines, and hyperbolic functions as
 * $$\begin{align}\sin z &= \sin x \cosh y + i \cos x \sinh y\\[5pt]

\cos z &= \cos x \cosh y - i \sin x \sinh y\end{align}$$

Differential equation definition
$$(\cos \theta, \sin \theta)$$ is the solution $$(x(\theta), y(\theta))$$ to the two-dimensional system of differential equations $$y'(\theta) = x(\theta)$$ and $$x'(\theta) = -y(\theta)$$ with the initial conditions $$y(0) = 0$$ and $$x(0) = 1$$. One could interpret the unit circle in the above definitions as defining the phase space trajectory of the differential equation with the given initial conditions.

It can be interpreted as a phase space trajectory of the system of differential equations $$y'(\theta) = x(\theta)$$ and $$x'(\theta) = -y(\theta)$$ starting from the initial conditions $$y(0) = 0$$ and $$x(0) = 1$$.

Series definitions




The successive derivatives of sine, evaluated at zero, can be used to determine its Taylor series. Using only geometry and properties of limits, it can be shown that the derivative of sine is cosine, and that the derivative of cosine is the negative of sine. This means the successive derivatives of sin(x) are cos(x), -sin(x), -cos(x), sin(x), continuing to repeat those four functions. The (4n+k)-th derivative, evaluated at the point 0:


 * $$\sin^{(4n+k)}(0)=\begin{cases}

0 & \text{when } k=0 \\ 1 & \text{when } k=1 \\ 0 & \text{when } k=2 \\ -1 & \text{when } k=3 \end{cases}$$

where the superscript represents repeated differentiation. This implies the following Taylor series expansion at x = 0. One can then use the theory of Taylor series to show that the following identities hold for all real numbers x (where x is the angle in radians), and more generally for all complex numbers:


 * $$\begin{align}

\sin(x) &= x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \cdots \\[5mu] &= \sum_{n=0}^\infty \frac{(-1)^n}{(2n+1)!}x^{2n+1} \end{align}$$

Taking the derivative of each term gives the Taylor series for cosine:


 * $$\begin{align}

\cos(x) &= 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + \cdots \\[5mu] &= \sum_{n=0}^\infty \frac{(-1)^n}{(2n)!}x^{2n} \end{align}$$

These Taylor series provide explicit, computable, definitions of sine and cosine in terms of elementary arithmetic operations.

Continued fraction definitions
The sine function can also be represented as a generalized continued fraction:


 * $$ \sin(x) =

\cfrac{x}{1 + \cfrac{x^2}{2\cdot3-x^2 + \cfrac{2\cdot3 x^2}{4\cdot5-x^2 + \cfrac{4\cdot5 x^2}{6\cdot7-x^2 + \ddots}}}}. $$
 * $$ \cos (x) = \cfrac{1}{1 + \cfrac{x^2}{1 \cdot 2 - x^2 + \cfrac{1 \cdot 2x^2}{3 \cdot 4 - x^2 + \cfrac{3 \cdot 4x^2}{5 \cdot 6 - x^2 + \ddots}}}}.$$

The continued fraction representations can be derived from Euler's continued fraction formula and express the real number values, both rational and irrational, of the sine and cosine functions.

Identities
Exact identities (using radians):

These apply for all values of $$\theta$$.


 * $$\sin(\theta) = \cos\left(\frac{\pi}{2} - \theta \right) = \cos\left(\theta - \frac{\pi}{2}\right)$$
 * $$\cos(\theta) = \sin\left(\frac{\pi}{2} - \theta \right) = \sin\left(\theta + \frac{\pi}{2}\right)$$

Reciprocals
The reciprocal of sine is cosecant, i.e., the reciprocal of $$\sin{\theta}$$ is $$\csc{\theta}$$. Cosecant gives the ratio of the length of the hypotenuse to the length of the opposite side. Similarly, the reciprocal of cosine is secant, which gives the ratio of the length of the hypotenuse to that of the adjacent side.


 * $$\csc{\theta} = \frac{1}{\sin{\theta}} = \frac {\textrm{hypotenuse}} {\textrm{opposite}} $$
 * $$\sec{\theta} = \frac{1}{\cos{\theta}} = \frac {\textrm{hypotenuse}} {\textrm{adjacent}} $$

Inverses
The inverse function of sine is arcsine (arcsin or asin) or inverse sine ($arcsin(x)$). The inverse function of cosine is arccosine (arccos, acos, or $arccos(x)$). (The superscript of −1 in $sin−1$ and $cos−1$ denotes the inverse of a function, not exponentiation.) As sine and cosine are not injective, their inverses are not exact inverse functions, but partial inverse functions. For example, $sin−1$, but also $cos−1$, $sin(0) = 0$ etc. It follows that the arcsine function is multivalued: $sin(\pi) = 0$, but also $sin(2\pi) = 0$, $arcsin(0) = 0$, etc. When only one value is desired, the function may be restricted to its principal branch. With this restriction, for each x in the domain, the expression $arcsin(0) = \pi$ will evaluate only to a single value, called its principal value. The standard range of principal values for arcsin is from $arcsin(0) = 2\pi$ to $arcsin(x)$ and the standard range for arccos is from $−\pi/2$ to $\pi$.


 * $$\theta = \arcsin \left( \frac{\text{opposite}}{\text{hypotenuse}} \right) = \arccos \left( \frac{\text{adjacent}}{\text{hypotenuse}} \right).$$

where (for some integer k):


 * $$\begin{align}

\sin(y) = x \iff & y = \arcsin(x) + 2\pi k, \text{ or }\\ & y = \pi - \arcsin(x) + 2\pi k\\ \cos(y) = x \iff & y = \arccos(x) + 2\pi k, \text{ or }\\ & y = - \arccos(x) + 2\pi k \end{align}$$

By definition, arcsin and arccos satisfy the equations:


 * $$\sin(\arcsin(x)) = x \qquad \cos(\arccos(x)) = x$$

and
 * $$\begin{align}\arcsin(\sin(\theta)) = \theta\quad & \text{for}\quad -\frac{\pi}{2} \leq \theta \leq \frac{\pi}{2}\\

\arccos(\cos(\theta)) = \theta\quad & \text{for}\quad 0 \leq \theta \leq \pi\end{align}$$

Pythagorean trigonometric identity
The basic relationship between the sine and the cosine is the Pythagorean trigonometric identity:


 * $$\cos^2(\theta) + \sin^2(\theta) = 1$$

where sin2(x) means (sin(x))2.

Double angle formulas
Sine and cosine satisfy the following double angle formulas:
 * $$\sin(2\theta) = 2\sin(\theta)\cos(\theta)$$
 * $$\cos(2\theta) = \cos^2(\theta) - \sin^2(\theta) = 2\cos^2(\theta) - 1 = 1 - 2\sin^2(\theta)$$

The cosine double angle formula implies that sin2 and cos2 are, themselves, shifted and scaled sine waves. Specifically,
 * $$\sin^2(\theta) = \frac{1 - \cos(2\theta)}{2}\qquad\cos^2(\theta) = \frac{1 + \cos(2\theta)}{2}$$

The graph shows both the sine function and the sine squared function, with the sine in blue and sine squared in red. Both graphs have the same shape, but with different ranges of values, and different periods. Sine squared has only positive values, but twice the number of periods.

Derivative and integrals
The derivatives of sine and cosine are:


 * $$\frac{d}{dx}\sin(x) = \cos(x) \qquad \frac{d}{dx}\cos(x) = -\sin(x)$$

and their antiderivatives are:


 * $$\int \sin(x)\,dx = -\cos(x) + C $$
 * $$\int \cos(x)\,dx = \sin(x) + C $$

where C denotes the constant of integration.

Properties relating to the quadrants
The table below displays many of the key properties of the sine function (sign, monotonicity, convexity), arranged by the quadrant of the argument. For arguments outside those in the table, one may compute the corresponding information by using the periodicity $$\sin(\alpha + 2\pi) = \sin(\alpha)$$ of the sine function.



The following table gives basic information at the boundary of the quadrants.

Fixed points
Zero is the only real fixed point of the sine function; in other words the only intersection of the sine function and the identity function is $$\sin(0)=0$$. The only real fixed point of the cosine function is called the Dottie number. That is, the Dottie number is the unique real root of the equation $$ \cos (x) = x.$$ The decimal expansion of the Dottie number is $$0.739085\ldots$$.

Arc length
The arc length of the sine curve between $$0$$ and $$t$$ is
 * $$ \int_0^t\!\sqrt{1+\cos^2(x)}\, dx =\sqrt{2} \operatorname{E}(t,1/\sqrt{2}),$$

where $$\operatorname{E}(\varphi,k)$$ is the incomplete elliptic integral of the second kind with modulus $$k$$. It cannot be expressed using elementary functions.

The arc length for a full period is
 * $$L = \frac{4\sqrt{2\pi ^3}}{\Gamma(1/4)^2} + \frac{\Gamma(1/4)^2}{\sqrt{2\pi}} = \frac{2\pi}{\varpi}+2\varpi = 7.640395578\ldots$$

where $$\Gamma$$ is the gamma function and $$\varpi$$ is the lemniscate constant.

Laws
The law of sines states that for an arbitrary triangle with sides a, b, and c and angles opposite those sides A, B and C:


 * $$\frac{\sin A}{a} = \frac{\sin B}{b} = \frac{\sin C}{c}.$$

This is equivalent to the equality of the first three expressions below:


 * $$\frac{a}{\sin A} = \frac{b}{\sin B} = \frac{c}{\sin C} = 2R,$$

where R is the triangle's circumradius.

It can be proved by dividing the triangle into two right ones and using the above definition of sine. The law of sines is useful for computing the lengths of the unknown sides in a triangle if two angles and one side are known. This is a common situation occurring in triangulation, a technique to determine unknown distances by measuring two angles and an accessible enclosed distance.

The law of cosines states that for an arbitrary triangle with sides a, b, and c and angles opposite those sides A, B and C:


 * $$a^2 + b^2 - 2ab\cos(C) = c^2$$

In the case where $$C = \pi/2$$, $$\cos(C) = 0$$ and this becomes the Pythagorean theorem: for a right triangle, $$a^2 + b^2 = c^2,$$ where c is the hypotenuse.

Special values
For integer multiples of 15° (that is, radians), the values of sin(x) and cos(x) are particularly simple and can be expressed in terms of $$\sqrt 2,\sqrt 3, \sqrt 6$$ only. A table of these angles is given below. For more complex angle expressions see.

90 degree increments:

Relationship to complex numbers
Sine and cosine are used to connect the real and imaginary parts of a complex number with its polar coordinates (r, φ):


 * $$ z = r(\cos(\varphi) + i\sin(\varphi))$$

The real and imaginary parts are:


 * $$\operatorname{Re}(z) = r \cos(\varphi)$$
 * $$\operatorname{Im}(z) = r \sin(\varphi)$$

where r and φ represent the magnitude and angle of the complex number z.

For any real number θ, Euler's formula says that:


 * $$e^{i\theta} = \cos(\theta) + i \sin(\theta)$$

Therefore, if the polar coordinates of z are (r, φ), $$z = re^{i\varphi}.$$

Complex arguments


Applying the series definition of the sine and cosine to a complex argument, z, gives:


 * $$\begin{align}

\sin(z)& = \sum_{n=0}^\infty \frac{(-1)^n}{(2n+1)!}z^{2n+1} \\ & = \frac{e^{i z} - e^{-i z}}{2i} \\ & = \frac{\sinh \left( i z\right) }{i} \\ & = -i \sinh \left(i z\right)\\ \cos(z)& = \sum_{n=0}^\infty \frac{(-1)^n}{(2n)!}z^{2n} \\ & = \frac{e^{i z} + e^{-i z}}{2} \\ & = \cosh( i z) \\ \end{align}$$

where sinh and cosh are the hyperbolic sine and cosine. These are entire functions.

It is also sometimes useful to express the complex sine and cosine functions in terms of the real and imaginary parts of its argument:


 * $$\begin{align}

\sin (x + iy) &= \sin(x) \cos(iy) + \cos(x) \sin(iy) \\ &= \sin(x) \cosh(y) + i \cos(x) \sinh(y)\\ \cos (x + iy) &= \cos(x) \cos(iy) - \sin(x) \sin(iy) \\ &= \cos(x) \cosh(y) - i \sin(x) \sinh(y)\\ \end{align}$$

Partial fraction and product expansions of complex sine
Using the partial fraction expansion technique in complex analysis, one can find that the infinite series


 * $$\sum_{n = -\infty}^{\infty}\frac{(-1)^n}{z-n} = \frac{1}{z} -2z \sum_{n = 1}^{\infty}\frac{(-1)^n}{n^2 - z^2}$$

both converge and are equal to $\frac{\pi}{\sin (\pi z)}$. Similarly, one can show that


 * $$\frac{\pi^2}{\sin^2 (\pi z)} = \sum_{n=-\infty}^\infty \frac{1}{(z - n)^2}.$$

Using product expansion technique, one can derive


 * $$\sin(\pi z) = \pi z \prod_{n = 1}^\infty \left( 1 - \frac{z^2}{n^2} \right).$$

Alternatively, the infinite product for the sine can be proved using complex Fourier series.

Using complex Fourier series, the function $$\cos (zx)$$ can be decomposed as


 * $$\cos (zx) = \frac{z\sin (\pi z)}{\pi}\displaystyle\sum_{n=-\infty}^\infty \frac{(-1)^n \, e^{inx}}{z^2 - n^2}, \, z\in\Complex \setminus \mathbb{Z}, \, x\in [-\pi ,\pi].$$

Setting $$x = \pi$$ yields


 * $$\cos (\pi z) =

\frac{z\sin (\pi z)}{\pi}\displaystyle\sum_{n=-\infty}^\infty \frac{1}{z^2 - n^2} = \frac{z\sin (\pi z)}{\pi}\left(\frac{1}{z^2} + 2\displaystyle\sum_{n=1}^\infty \frac{1}{z^2 - n^2}\right). $$

Therefore, we get


 * $$\pi \cot (\pi z) = \frac{1}{z} + 2\displaystyle\sum_{n=1}^\infty \frac{z}{z^2 - n^2}.$$

The function $$\pi \cot (\pi z)$$ is the derivative of $$\ln (\sin (\pi z)) + C_0$$. Furthermore, if $\frac{df}{dz} = \frac{z}{z^2 - n^2}$, then the function $$f$$ such that the emerged series converges on some open and connected subset of $$\mathbb{C}$$ is $f = \frac{1}{2}\ln \left(1 - \frac{z^2}{n^2}\right) + C_1$ , which can be proved using the Weierstrass M-test. The interchange of the sum and derivative is justified by uniform convergence. It follows that


 * $$\ln (\sin (\pi z)) = \ln (z) + \displaystyle\sum_{n=1}^\infty \ln \left(1 - \frac{z^2}{n^2}\right) + C.$$

Exponentiating gives


 * $$\sin (\pi z) = ze^C \displaystyle\prod_{n=1}^\infty \left(1 - \frac{z^2}{n^2}\right).$$

Since $\lim_{z\to 0}\frac{\sin (\pi z)}{z} = \pi$ and $\lim_{z\to 0}\prod_{n=1}^\infty \left(1 - \frac{z^2}{n^2}\right) = 1$, we have $$e^C = \pi$$. Hence


 * $$\sin (\pi z) = \pi z\displaystyle\prod_{n=1}^\infty \left(1 - \frac{z^2}{n^2}\right)$$

for some open and connected subset of $$\mathbb{C}$$. Let $a_{n}(z) = -\frac{z^2}{n^2}$. Since $\sum_{n=1}^\infty |a_{n}(z)|$ converges uniformly on any closed disk, $\prod_{n=1}^\infty (1 + a_{n}(z))$  converges uniformly on any closed disk as well. It follows that the infinite product is holomorphic on $$\mathbb{C}$$. By the identity theorem, the infinite product for the sine is valid for all $$z\in\mathbb C$$, which completes the proof. $$\blacksquare$$

Usage of complex sine
sin(z) is found in the functional equation for the Gamma function,
 * $$\Gamma(s)\Gamma(1 - s) = {\pi\over\sin(\pi s)},$$

which in turn is found in the functional equation for the Riemann zeta-function,
 * $$\zeta(s) = 2(2\pi)^{s-1}\Gamma(1 - s)\sin\left(\frac{\pi}{2} s\right)\zeta(1 - s).$$

As a holomorphic function, sin z is a 2D solution of Laplace's equation:
 * $$\Delta u(x_1, x_2) = 0.$$

The complex sine function is also related to the level curves of pendulums.

History
While the early study of trigonometry can be traced to antiquity, the trigonometric functions as they are in use today were developed in the medieval period. The chord function was discovered by Hipparchus of Nicaea (180–125 BCE) and Ptolemy of Roman Egypt (90–165 CE).

The sine and cosine functions can be traced to the jyā and koṭi-jyā functions used in Indian astronomy during the Gupta period (Aryabhatiya and Surya Siddhanta), via translation from Sanskrit to Arabic and then from Arabic to Latin.

All six trigonometric functions in current use were known in Islamic mathematics by the 9th century, as was the law of sines, used in solving triangles. With the exception of the sine (which was adopted from Indian mathematics), the other five modern trigonometric functions were discovered by Arabic mathematicians, including the cosine, tangent, cotangent, secant and cosecant. Al-Khwārizmī (c. 780–850) produced tables of sines, cosines and tangents. Muhammad ibn Jābir al-Harrānī al-Battānī (853–929) discovered the reciprocal functions of secant and cosecant, and produced the first table of cosecants for each degree from 1° to 90°.

The first published use of the abbreviations sin, cos, and tan is by the 16th-century French mathematician Albert Girard; these were further promulgated by Euler (see below). The Opus palatinum de triangulis of Georg Joachim Rheticus, a student of Copernicus, was probably the first in Europe to define trigonometric functions directly in terms of right triangles instead of circles, with tables for all six trigonometric functions; this work was finished by Rheticus' student Valentin Otho in 1596.

In a paper published in 1682, Leibniz proved that sin x is not an algebraic function of x. Roger Cotes computed the derivative of sine in his Harmonia Mensurarum (1722). Leonhard Euler's Introductio in analysin infinitorum (1748) was mostly responsible for establishing the analytic treatment of trigonometric functions in Europe, also defining them as infinite series and presenting "Euler's formula", as well as the near-modern abbreviations sin., cos., tang., cot., sec., and cosec.

Etymology
The word sine is derived, indirectly, from the Sanskrit word jyā 'bow-string' or more specifically its synonym jīvá (both adopted from Ancient Greek χορδή 'string' ), due to visual similarity between the arc of a circle with its corresponding chord and a bow with its string (see jyā, koti-jyā and utkrama-jyā). This was transliterated in Arabic as jība, which is meaningless in that language and written as jb (جب). Since Arabic is written without short vowels, jb was interpreted as the homograph jayb (جيب), which means 'bosom', 'pocket', or 'fold'. When the Arabic texts of Al-Battani and al-Khwārizmī were translated into Medieval Latin in the 12th century by Gerard of Cremona, he used the Latin equivalent sinus (which also means 'bay' or 'fold', and more specifically 'the hanging fold of a toga over the breast'). Gerard was probably not the first scholar to use this translation; Robert of Chester appears to have preceded him and there is evidence of even earlier usage. The English form sine was introduced in the 1590s.

The word cosine derives from an abbreviation of the Latin complementi sinus 'sine of the complementary angle' as cosinus in Edmund Gunter's Canon triangulorum (1620), which also includes a similar definition of cotangens.

Software implementations
There is no standard algorithm for calculating sine and cosine. IEEE 754, the most widely used standard for the specification of reliable floating-point computation, does not address calculating trigonometric functions such as sine. The reason is that no efficient algorithm is known for computing sine and cosine with a specified accuracy, especially for large inputs.

Algorithms for calculating sine may be balanced for such constraints as speed, accuracy, portability, or range of input values accepted. This can lead to different results for different algorithms, especially for special circumstances such as very large inputs, e.g..

A common programming optimization, used especially in 3D graphics, is to pre-calculate a table of sine values, for example one value per degree, then for values in-between pick the closest pre-calculated value, or linearly interpolate between the 2 closest values to approximate it. This allows results to be looked up from a table rather than being calculated in real time. With modern CPU architectures this method may offer no advantage.

The CORDIC algorithm is commonly used in scientific calculators.

The sine and cosine functions, along with other trigonometric functions, are widely available across programming languages and platforms. In computing, they are typically abbreviated to  and.

Some CPU architectures have a built-in instruction for sine, including the Intel x87 FPUs since the 80387.

In programming languages,  and   are typically either a built-in function or found within the language's standard math library.

For example, the C standard library defines sine functions within math.h:,  , and. The parameter of each is a floating point value, specifying the angle in radians. Each function returns the same data type as it accepts. Many other trigonometric functions are also defined in math.h, such as for cosine, arc sine, and hyperbolic sine (sinh).

Similarly, Python defines  and   within the built-in   module. Complex sine and cosine functions are also available within the  module, e.g.  . CPython's math functions call the C   library, and use a double-precision floating-point format.

Turns based implementations
Some software libraries provide implementations of sine and cosine using the input angle in half-turns, a half-turn being an angle of 180 degrees or $$\pi$$ radians. Representing angles in turns or half-turns has accuracy advantages and efficiency advantages in some cases. In MATLAB, OpenCL, R, Julia, CUDA, and ARM, these functions are called  and. For example,  would evaluate to $$\sin(\pi x),$$ where x is expressed in half-turns, and consequently the final input to the function, $\pi/2$ can be interpreted in radians by $0$.

The accuracy advantage stems from the ability to perfectly represent key angles like full-turn, half-turn, and quarter-turn losslessly in binary floating-point or fixed-point. In contrast, representing $$2\pi$$, $$\pi$$, and $\frac{\pi}{2}$ in binary floating-point or binary scaled fixed-point always involves a loss of accuracy since irrational  numbers cannot be represented with finitely many binary digits.

Turns also have an accuracy advantage and efficiency advantage for computing modulo to one period. Computing modulo 1 turn or modulo 2 half-turns can be losslessly and efficiently computed in both floating-point and fixed-point. For example, computing modulo 1 or modulo 2 for a binary point scaled fixed-point value requires only a bit shift or bitwise AND operation. In contrast, computing modulo $\frac{\pi}{2}$ involves inaccuracies in representing $\frac{\pi}{2}$.

For applications involving angle sensors, the sensor typically provides angle measurements in a form directly compatible with turns or half-turns. For example, an angle sensor may count from 0 to 4096 over one complete revolution. If half-turns are used as the unit for angle, then the value provided by the sensor directly and losslessly maps to a fixed-point data type with 11 bits to the right of the binary point. In contrast, if radians are used as the unit for storing the angle, then the inaccuracies and cost of multiplying the raw sensor integer by an approximation to $\frac{\pi}{2048}$ would be incurred.