<s>[INST] How to compute $\cos(\arctan(2)) = 1/\sqrt{5}$ I'm doing matrices and I rotated a line about an angle. The gradient of my line I'm rotating to the $x$-axis is $2$, from $y=2x$. So obviously the angle that the line $y=2x$ makes with the $x$-axis is $\arctan(2)$.
My question is how do I arrive at  $\cos(\arctan(2)) = 1/\sqrt{5}$. <---
The $1/\sqrt{5}$ is what I'm confused with, how do I get this?
 [/INST] Well..
Let $\arctan 2 = x$.
$\arctan (2) = x \implies \tan x = \sin x/\cos x = 2 \implies \sin x = 2 \cos x \implies  \sin^2 x + \cos^2 x =  4\cos^2 x + \cos^2 x = 1 \implies \cos^2 x = 1/5 \implies \cos x = \pm 1/\sqrt{5}$.
By convention $\arctan$ takes values in (-$\pi/2, \pi/2$) where $\cos$ is presumed to be positive.  So $\cos x = 1/\sqrt{5}$.
====
In general if $\tan x = b$ then $\sin x = b \cos x$ so $\sin^2 x + \cos^2 x = (b^2 + 1) \cos^2 x$ so $\cos x = 1/\sqrt{b^2 + 1}$ and hence the trig identity $\cos x = 1/\sqrt{\tan^2 x + 1}$ which is, confession time, one of those trig identities I absolutely can not remember and derive every single time.
</s>