Maximum and minimum of $\cos^2x+\sin^2y$, where $x-y=\pi/4$ and $0\leq x\leq \pi $ In the book "Calculus of several variables" by Sege Lang in page 144 the author proposes the following problema: 
Find the extreme values of the function $$f(x,y)=\cos^2x + \cos^2y$$  subject to the constraint $x - y = \pi/4$   and $0\leq x\leq \pi$.
I have some difficulty in solving this problema. I tried to substitute $y$ by $x-\frac{\pi}{4}$ and get a function $g$ of a single variable: 
$$g(x)=\cos^2x+\frac{1}{2}(\cos x+\sin x)^2$$
Now to find the extreme values   of the function g I'm trying to solve the equation:
$$\frac{d g}{dx}=-2\cos x\sin x+(\cos x+\sin x)(\cos x-\sin x)=-2\cos x\sin x+ \cos^2x-\sin^2x=0$$
I can not find the solutions of this last euquation. Anyone have an idea?
 A: I don't see any flaws in the solution. In the last equation, you can use the identities
$$2\sin(x)\cos(x) = \sin(2x)$$
and
$$\cos^2(x)-\sin^2(x) = \cos(2x)$$
to have
$$\cos(2x)-\sin(2x) = 0 \implies \tan(2x) = 1 \implies x = \frac{\pi}{8} \lor x=\frac{5\pi}{8}$$
Then you can put these values on $g(x)$ to find extreme values of the function.
A: Hint: Your function $g(x)$ is equal to $$g(x)=\cos^2(x)+\frac{1}{2}(1+\sin(2x))$$ and your first derivative is given by 
$$g'(x)=\cos (2 x)-2 \sin (x) \cos (x)=\cos(2x)-\sin(2x)$$
A: By C-S
$$\cos^2x+\sin^2y=\cos^2x+\sin^2\left(x-\frac{\pi}{4}\right)=$$
$$=\frac{1+\cos2x}{2}+\frac{1}{2}(1-2\sin{x}\cos{x})=1+\frac{1}{2}(\cos2x-\sin2x)\leq$$
$$\leq1+\frac{1}{2}\sqrt{(1^2+1^2)(\cos^22x+(-\sin2x)^2)}=1+\frac{1}{\sqrt2}.$$
The equality occurs, when $(1,1)||(\cos2x,-\sin2x),$ which says that we got a maximal value.
By the same way we can got a minimal value:
$$1-\frac{1}{\sqrt2}.$$
A: You're just finding the extreme values of $$\cos^2(x)+\sin^2(x-\frac \pi4)$$
$$\sin(x-\frac \pi4) = \frac{1}{\sqrt 2}(\sin(x)-\cos(x))$$
A: Using Prove $ \sin(A+B)\sin(A-B)=\sin^2A-\sin^2B $,
$$\cos^2x+\sin^2y=1-\sin(x+y)\sin(x-y)$$
$$=1-\sin\dfrac\pi4\sin(2x+\dfrac\pi4)$$
Now $-1\le\sin(2x+\dfrac\pi4)\le1$
A: Your last equation simply becomes $\sin 2x = \cos 2x$, so solving $\tan 2x =1$ yields critical points at $\frac{\pi}{8}, \frac{5 \pi}{8}$.
As a side note, it is possible to see these were local maxima/minima immediately; $x$ and $y$ differ by $\frac{\pi}{4}$, and these points are the points where the interval is centred at a max or min of $\cos^2$. Moving the interval to be left or right is the same due to symmetry so these points are critical points.
