why is $\cos^2(\theta) + \sin^2(\theta)$ always approximately $1$ I'm doing an exercise from a computer programming book and was asked to determine the following:

why is $\cos^2(\theta) + \sin^2(\theta)$ always approximately $1$ for any theta?

Can someone please explain why the result is always approximately $1$? 
 A: Because in math, it is exactly $1$. I have no experience in programming but presumably, when you write a program to approximate $\cos^2\theta+\sin^2\theta$, it will always give something close to the exact value. Here's a short proof. Let $\theta$ be an angle in a right angled triangle, and let the lengths of the adjacent side to that angle, the opposite side, and the hypotenuse be $\mathrm{adj.}$, $\mathrm{opp.}$ and $\mathrm{hyp.}$ respectively.
$$\begin{split}\cos^2\theta+\sin^2\theta & = \left(\frac{\mathrm{adj.}}{\mathrm{hyp}}\right)^2 +  \left(\frac{\mathrm{opp.}}{\mathrm{hyp}}\right)^2\\
& = \frac{\mathrm{adj.}^2+\mathrm{opp.}^2}{\mathrm{hyp.}^2}\\
& =^* \frac{\mathrm{hyp.}^2}{\mathrm{hyp.}^2}\\
& = 1.
\end{split}$$
Note that the starred equality $=^*$ follows because of the Pythagorean Theorem.
A: Most computer implementations of $\sin$ and $\cos$ rely on their Taylor series approximation. If you consider the degree $n$ Taylor polynomial for $\sin(x)$ and $\cos(x)$, square them, and add them, you'll see that all the coefficients of $x^1$ to $x^{2n-1}$ vanish, so the Taylor series of $\sin^2(x) + \cos^2(x)$ turns out to be $1 + c_{2n}x^{2n}$, and for large enough values of $n$, this is close to $1$. That's why your calculator/computer will often tell you $\sin^2(x) + \cos^2(x)$ is approximately $1$. In fact, it turns out that it's exactly $1$, as the other answers point out.
A: $\cos^2(\theta) + \sin^2(\theta)$ is always equal to $1$ in the mathematical world. This is the Pythagorean Theorem.
In the computer world, this is not so because computer arithmetic has limited precision. Moreover, even when $\theta$ is given in degrees as a fraction, $\sin^2(\theta)$ is never a fraction, except in three cases. This is Niven's theorem.
On the other hand, this does not mean that $\cos^2(\theta) + \sin^2(\theta)$ is never exactly $1$ in a computer. Actually, it is exactly $1$ for many values of $\theta$. Indeed, this program shows that it is exactly $1$ for over 75% of 32000+ rational numbers uniformly distributed in the interval $[0,6.25]$.
The reason is probably that  $\cos^2(\theta) + \sin^2(\theta)=1$ is used in the computation of $\cos(\theta)$ and $\sin(\theta)$. Moreover, and more importantly, these values are computed to be correct up to one unit in the last place, at least for $\theta$ not very large. If you print the errors $v-1.0$ in that program, you'll see this.
A: Near 0 we have approximations:
$$ \cos(\theta) = 1 - \frac{\theta^2}{2} + O(\theta^3),\quad \sin(\theta) = \theta + O(\theta^3)$$
Thus, near 0,
$$ \sin^2(\theta) + \cos^2(\theta)  \approx (1 - \frac{\theta^2}{2})^2 + \theta^2 = 1. $$
This is correct up to $O(\theta^4)$.
A: On the unit circle is a right triangle with radius $1$. By definition $\theta$ is the angle between the $x$-axis and the segment forming the hypotenuse of the triangle. 
Let's define $s_1$ as the side opposite to $\theta$. Recall that the hypotenuse of the triangle is $1$. Therefore, $$\sin \theta=\frac{s_1}{1}=s_1$$
Then, let's define the leg of the triangle adjacent to $\theta$ as $s_2$. Again using SOHCAHTOA, $$s_2=\cos\theta$$
Then, using the Pythagorean Theorem, $$s_1^2+s_2^2=1^2=1$$
Therefore, $$\sin^2\theta +\cos^2\theta=1$$
This is rightfully called the Pythagorean Identity.
