# Maximizing a Trigonometric Expression: asin(x)+bcos(x).

I came across a maximization problem involving trigonometric expressions that I thought was interesting. It might be quite standard, but I have never seen it before. The problem is to maximize the expression \[a \sin x + b \cos x\] where \(a, b \in \R\) are fixed constants and \(x \in \R\) is any real number. Without loss or generality, assume that \(a\neq 0\) and \(b\neq 0\).

## Proof and Result

We begin by trying to combine the two terms using trigonometry. Notice that
\[r\sin(x+\varphi) = r\cos\varphi\sin x + r\sin\varphi\cos x.\]
We can then define
\[a = r\cos\varphi, b = r\sin\varphi,\]
to obtain that
\[a\sin x + b\cos x = r\sin(x+\varphi) \leq r.\]
It is clear that the maximum value of the right-hand side occurs when \(\sin(x+\varphi)\) is equal to one and the RHS^{1} is equal to \(r\). Now it remains for us to find the value of \(r\). Dividing our definitions for \(a\) and \(b\), we see that
\[\frac{b}{a} = \frac{r\cos\varphi}{r\sin\varphi} = \tan\varphi,\]
and hence,
\[\varphi = \arctan\frac{b}{a}.\]
We can then plug this in to solve for \(r\). Note that
\[\cos\varphi = \cos\arctan\frac{b}{a} = \frac{a}{\sqrt{a^2+b^2}}.\]
This result could be obtained by construcing a reference right triangle with opposite side \(b\), adjacent side \(a\), and hence hypotenuse \(\sqrt{a^2+b^2}\). Finally,
\[r = \frac{a}{\cos\varphi} = \frac{a}{\frac{a}{\sqrt{a^2+b^2}}} = \sqrt{a^2+b^2},\]
and we have found the maximum value of \(a\sin x + b\cos x\). Similarly, since \(\sin(x+\varphi) \geq -1\), we also have that \(a\sin x + b\cos x \geq -r = -\sqrt{a^2 + b^2}\). Therefore,
\[\max_{x \in \R}(a\sin x + b\cos x) = \sqrt{a^2 + b^2}, \; \min_{x \in \R}(a\sin x + b\cos x) = -\sqrt{a^2 + b^2}.\]

## An Application

This application was inspired by a few comment suggestions under this YouTube Video, The problem presented in the video is as follows. Given that \(x^2 + y^2 = 4\), maximize \(3x+4y\). We immediately notice the potential benefit of trigonometric substitution because the given statement is in the form of the pythagorean identity. Setting \(x = 2\cos\theta\) and \(y = 2\sin\theta\), the given equation becomes \[4\cos^2 \theta + 4\sin^2 \theta = 4,\] which is automatically satisfied by any \(\theta\in\R\). Then, our expression to maximize becomes \[3(2\cos\theta) + 4(2\sin\theta) = 6\cos\theta + 8\sin\theta.\] Applying our result, we see that \[\max_{x^2 + y^2 = 4}(3x+4y) = \max_{\theta \in \R}(8\sin\theta + 6\cos\theta) = \sqrt{8^2 + 6^2} = 10.\] And similarly, its minimum is \(-10\).

We could also visualize this problem in \(\R^3\) (3-space). We are dealing with a ring characterized by the intersection of the cylinder \(x^2 + y^2 = 4\) and the plane \(z = 3x+4y\). In the substitution step, we have effectively parametrized this ring. Taking this one step further, we find that the ring of interest could be fully parametrized as
\[\vec{r}(\theta) = \langle 2\cos\theta, 2\sin\theta, 8\sin\theta + 6\cos\theta \rangle,\]
where \(\theta\in[0,2\pi)\). Our desired maximum is now the maximum value that our ring achieves in the \(z\)-axis. We could also opt to quickly verify our result using calculus.^{2}