<s>[INST] Using an auxiliary triangle to find the range of a trig function such as $f(x)=a\sin x\pm b\cos x$ I read online that when finding range of a trigonometric function such as
$$f(x) = a\sin x \pm b\cos x$$
as shown in the image, we make a triangle and assign those values of constant in it.

*

*I did not understand that why is $a$ the base and $b$ perpendicular, and why not the opposite way.

*How did we predict by looking at that equation #3 and say the range?


 [/INST] You can also do the other way as you stated.
Now,
$\cos\theta = \frac{b}{\sqrt{a^2+b^2}}$ and $\sin\theta = \frac{a}{\sqrt{a^2+b^2}}$
$\Rightarrow a= \sqrt{a^2+b^2}\sin\theta$ and $b= \sqrt{a^2+b^2}\cos\theta$
$\Rightarrow f(x) = \sqrt{a^2+b^2}\left[\sin\theta\sin x \pm \cos\theta\cos x\right] =  \sqrt{a^2+b^2}\left[\mp\cos(x\pm\theta)\right]$
The range of $\cos\alpha $ is $[-1,1]$
So, range of $f(x)$ is $[-\sqrt{a^2+b^2},\sqrt{a^2+b^2}] $
</s>