Lagrange multipliers with trigonometric functions. Stucked figuring out x and y values.

1.3k Views Asked by At

I want to find the maximum of the function $f(x,y) = \cos^2(x) + \cos^2(y)$ with the constraint $x-y = \pi/4$.

Here are my partial derivatives:

$$f_x = -2\cos(x)\cdot\sin(x)$$ $$f_y = -2\cos(y)\cdot\sin(y)$$ $$g_x = 1$$ $$g_y = -1$$

I have the following system of equations: \begin{align*} -2\cos(x)\cdot\sin(x) = \lambda\\ -2\cos(y)\cdot\sin(y) = -\lambda\\ x-y = \pi/4 \end{align*}

And from this I got from 1 and 2 equation the equality:

$-2\cos(x)\cdot\sin(x) = 2\cos(y)\cdot\sin(y)$

and we can simplify this to: $\sin(2x) = -\sin(2y)$

And what should I do next in order to find maximum of this function? Also checked by Wolframa, that global maximum doesn't exist. Only global maximums. How can I check the existence of global maximum and minimum in such cases?

2

There are 2 best solutions below

0
On

OK, first off, I believe you should end up with:

$$ \sin(2x) = -\sin(2y) \\ \sin(2x) = \sin(-2y) $$

You need to be very careful with sine because it's not simply true that $2x = -2y \rightarrow y = -x$. First off, the sines are equal not only when the two arguments are equal but also when they differ by $2\pi n$, so we would really have: $2x = -2y+2\pi n \rightarrow y = -x +\pi n$. To further complicate things, over the range of $2\pi$, other than for $\frac{\pi}{2}$ and $\frac{3\pi}{2}$, the sine will always have two distinct angles where it is equal.

Let's assume that an angle $\theta$ is in the first quadrant, then $\sin(\theta) = \sin(\pi - \theta)$ (this can be verified via the unit circle). It can then also be verified to work if $\theta$ is in the second quadrant (it will just give us back the first quadrant angle). Finally you can verify that it also works for angles in the third and fourth quadrants. If you want to be certain, you can always use the angle addition formula:

\begin{align} \sin(\pi-\theta) =&\ \cos(\pi)\sin(-\theta) + \cos(\theta)\sin(\pi) \\ =&\ -\sin(-\theta) \\ =&\ \sin(\theta) \end{align}

Therefore we actually have that:

$$ 2x = -2y + 2\pi n \rightarrow y = -x + \pi n\\ 2x + 2\pi m = \pi + 2y \rightarrow y = x - \frac{\pi}{2} + \pi m $$

(I chose the side to put the $+2\pi n$ on so that it stayed positive although that's not necessary since $m$,$n$ can also be negatives)

These need to be plugged into your constraint equation:

$$ x - y = x + x - \pi n = \frac{\pi}{4}\\ x = \frac{\pi}{8} + \frac{\pi n}{2} $$

and

$$ x - y = \frac{\pi}{2} - \pi m = \frac{\pi}{4} \\ m = \frac{1}{2} - \frac{1}{4} \notin \mathbb{Z} $$

It's good that the second set had no solutions (for the constraint equation) since the $x$'s dropped out. If we had found an integer $m$ then there would have been an infinite number of solutions (i.e any value of $x$ would have been a critical point).

Finally let's find $y$ given $x$:

\begin{align} y =&\ x - \frac{\pi}{4} \\ =&\ \frac{\pi}{8} + \frac{\pi n}{2} - \frac{\pi}{4}\\ =&\ -\frac{\pi}{8} + \frac{\pi n}{2} \end{align}

Plug into your original function (but first I'm going to use the following):

$$ \cos^2(\theta) = \frac{1 + \cos(2\theta)}{2} $$

So we have:

\begin{align} f(x^*, y^*) =&\ \frac{1}{2} + \frac{1}{2} + \frac{1}{2}\left(\cos\left(2\left(\frac{\pi}{8} + \frac{\pi n}{2}\right)\right) + \cos\left(2\left(-\frac{\pi}{8} + \frac{\pi n}{2}\right)\right)\right) \\ =&\ 1 + \frac{1}{2}\left(\cos\left(\frac{\pi}{4} + \pi n\right) + \cos\left(-\frac{\pi}{4} + \pi n\right)\right) \\ =&\ 1 + \frac{1}{2}\left(\cos\left(\frac{\pi}{4}\right)\cos(\pi n) + \cos\left(-\frac{\pi}{4}\right)\cos(\pi n)\right) \\ =&\ 1 + \cos\left(\frac{\pi}{4}\right)(-1)^{n} \end{align}

(note that $\cos(\pi n) = (-1)^{n}$--again, look at your unit circle)

This now gives your maxima and minima:

$$ f(x^*, y^*) = \begin{cases} 1 + \frac{1}{\sqrt{2}} & n \text{ even} \\ 1 - \frac{1}{\sqrt{2}} & n \text{ odd} \end{cases} $$

Finding critical points without Lagrange Multipliers

This answer can be further verified because this particular problem doesn't really "require" Lagrange Multipliers since the constraint equation is so simple:

$$ y = x - \frac{\pi}{4} $$

You can then plug that into your function $f(x,y)$ to obtain a function of a single variable:

\begin{align} g(x) =&\ 1 + \frac{\cos(2x) + \cos\left(2\left(x - \frac{\pi}{4}\right)\right)}{2}\\ =&\ 1 + \frac{\cos(2x) + \cos\left(2x - \frac{\pi}{2}\right)}{2} \\ =&\ 1 + \frac{\cos(2x) + \cos(2x)\cos\left(\frac{\pi}{2}\right) + \sin(2x)\sin\left(\frac{\pi}{2}\right)}{2} \\ =&\ 1 + \frac{\cos(2x) + \sin(2x)}{2} \end{align}

(since $\cos\left(\frac{\pi}{2}\right) = 0$ and $\sin\left(\frac{\pi}{2}\right) = 1$)

Now find the critical points by setting the derivative to zero:

$$ g'(x) = -\sin(2x) + \cos(2x) $$

Find $g'(x) = 0$:

$$ \sin(2x) - \cos(2x) = 0 \\ \cos(2x)\left(\tan(2x) - 1\right) = 0 \\ \tan(2x) = 1 $$

(we don't need to worry about $\cos(2x) = 0$ in the above since we can only factor out if $\cos(2x) \neq 0$)

Finally we know that $\tan(X) = 1$ when $X = \frac{\pi}{4} + \pi n$ therefore we have:

$$ 2x = \frac{\pi}{4} + \pi n \\ x = \frac{\pi}{8} + \frac{\pi n}{2} $$

Since this is exactly what we got for the critical points of $x$ above, the steps would now be the same to find the maxima and minima (i.e. plug into the original function).

0
On

Why use Lagrange multipliers for this problem? Putting $x=y+\frac{\pi}{4}$, we have essentially a function of single variable $$\cos(y+\pi/4)^2+\cos^2y=1+\frac{1}{\sqrt2}\cos(2y+\frac{\pi}{4})$$ which has maximum value $1+\frac{1}{\sqrt2}$ and minimum value $1-\frac{1}{\sqrt2}$.