Rectangle in a circle of radius a that maximizes x^n+ y^n 
Consider a rectangle with sides $2x$ and $2y$ inscribed in a given fixed circle $$x^2 + y^2 = a^2,$$ and let $n$ be a positive number. We wish to find the rectangle that maximizes the quantity $$z = x^n + y^n.$$ If $n = 2$, it is clear that $z$ has the constant value $a^2$ for all rectangles.

*

*If $n < 2$, show that the square maximizes $z$; and

*if $n > 2$, show that $z$ is maximized by a degenerate rectangle in which $x$ or $y$ is $0$.


My approach.
$$x^2 + y^2 = a^2$$
$$\therefore\, y = (a^2 - x^2)^{1\over 2}$$
\begin{align}
z &= x^n + y^n \\
{d\over dx}z & = nx^{n-1} - nx(a^2-x^2)^{n-2\over 2}
\end{align}
Equating with $0$ gives:
$$nx^{n-1} = nx(a^2-x^2)^{n-2\over 2}$$
$$x^{n-2} = (a^2 - x^2)^{n-2\over 2}$$
Squaring on both sides gives:
$$(x^2)^{n-2} = (a^2 - x^2)^{n-2}$$
Taking $\ln$ on both sides gives
$$(n-2) \ln(x^2) = (n-2)\ln(a^2 - x^2)$$33
Equating $x^2 = a^2 - x^2$ , we get $x = {a\over \sqrt{2}}$ and $y = {a\over\sqrt{2}}$. In particular $x=y$ implies that the optimal rectange is a square.
My computation appears to be independent of $n$, so I am puzzled about the statement in the question for $n>2$ and $n<2$.

For $n < 2$ your expression for $\frac{dz}{dx}$ is not defined where $y = 0$, so one must check those points separately. Also, between the two equations following, "equating it with $0$...", division by $0$ assumes that $x \neq 0$.

Here's an alternative approach: This problem is a typical candidate for the method of Lagrange multipliers, and applying that method has the advantage that it leaves $x$ and $y$ on equal footing and in particular avoid the complications introduced by solving (partially) for $y$ in terms of $x$.
Our objective function is $$f(x, y) := x^n + y^n ,$$ and our constraint is $g(x, y) = 0$, where
$$g(x, y) := x^2 + y^2 - a^2 .$$ (Herein I'll assume $a > 0$, so that the circle is nondegenerate.)
By symmetry we may as well assume that any (constrained, local) extremum $(c, d)$ lies in the closed first quadrant, i.e., are both nonnegative.

In fact, if $c = 0$, then the constraint implies $d = a$, and vice versa, so if a (constrained, local) extremum occurs where $c = 0$ or $d = 0$, its value is $f(a, 0) = f(0, a) = a^n$, and we may as well restrict the rest of our search to the interior of the first quadrant, i.e., the case $c, d > 0$.

The method of Lagrange multipliers yields that any (constrained, local) extremum $(c, d)$ satisfies $$(\nabla f)(c, d) = \lambda (\nabla g)(c, d) ,$$
that is, the system
\begin{align}
n c^{n - 1} &= 2 c \lambda \\
n d^{n - 1} &= 2 d \lambda .
\end{align}

Dividing the first equation by the second equation and rearranging yields $c^{n - 2} = d^{n - 2}$, so either (a) $n = 2$ (which corresponds to the tautology that there is a maximum at every point on the unit circle), or (b) the only critical point is $c = d = \frac{a}{\sqrt{2}}$. In the latter case computing gives $f\left(\frac{a}{\sqrt{2}}, \frac{a}{\sqrt{2}}\right) = a^n (\sqrt{2})^{2 - n} ,$ and whether this quantity is greater than $f(a, 0) = f(0, a) = a^n$ manifestly depends just on the sign of $2 - n$.

