# Maximize a function of $x$ and $y$ where $x^2 +y^2 \leq 1$

I have the following function: $$f(x,y) = x(y^2-x^2)- \frac{(x^2 +y^2)^2}{2\rho}+\frac{3x^2(y^2-4x^2)}{\rho}$$ where $$\rho>0$$ is a constant.

My goal is to find the maximum value of this function subject to the constraint $$x^2 +y^2 \leq 1$$.

What is the best way to solve this problem?

My thoughts:

1. I think I can replace the second term $$\frac{(x^2 +y^2)^2}{2\rho}$$ with $$\frac{1}{2\rho}$$ since due to the constraint $$x^2 +y^2 \leq 1$$.

But, I am not sure how to proceed. Can someone show me the steps for solving this problem? What would be the easiest way to approach this?

• Try this: Maximize[{x (y^2 - x^2) - (x^2 + y^2)^2/(2 rho) + (3 x^2 (y^2 - 4 x^2))/rho, x^2 + y^2 <= 1, rho > 0}, {x, y}]. And you'll see that it depends on the parameter value of $\rho$.
– ppp
Jan 29 at 2:27
• @ppp Is there a way to solve this in mathematical online? I am new to mathematica Jan 29 at 2:43
• I know there is a free access to Mathematica online for students.
– ppp
Jan 29 at 2:51
• @wanderer For this problem you can use the free online WolframAlpha. Substitute r for rho and Maximize[{x(y^2-x^2)-(x^2+y^2)^2/(2 r)+(3 x^2(y^2-4 x^2))/r,x^2+y^2<=1,r>0},{x,y}] returns a solution in 15 seconds. It goes on to try to do a bunch of additional calculations and formatting, but times out before finishing that, but you got the solution before that
– Bill
Jan 29 at 3:15

$Version (* "14.0.0 for Mac OS X ARM (64-bit) (December 13, 2023)" *) Clear["Global*"] f[x_, y_] := x (y^2 - x^2) - (x^2 + y^2)^2/(2 ρ) + 3 x^2 (y^2 - 4 x^2)/ρ MaxValue[{f[x, y], x^2 + y^2 <= 1, 0 < ρ}, {x, y, ρ}] (* 1 *) Maximize[{f[x, y], x^2 + y^2 <= 1, 0 < ρ}, {x, y, ρ}] (* Maximize::natt: The maximum is not attained at any point satisfying the given constraints. {1, {x -> -1, y -> 0, ρ -> ComplexInfinity}} *) f[-1, 0] (* 1 - 25/(2 ρ) *) Limit[f[-1, 0], ρ -> ∞] (* 1 *)  EDIT: If ρ has a fixed value, the maximum is a complicated Piecewise expression that depends on the specific value of ρ max = Assuming[ρ > 0, MaxValue[{f[x, y], x^2 + y^2 <= 1, 0 < ρ}, {x, y}] // FullSimplify]  • Thank you. I am having some trouble understanding. Could you please explain the result? Is the maximum value 1? What does this mean? "(* Maximize::natt: The maximum is not attained at any point satisfying the given constraints. {1, {x -> -1, y -> 0, ρ -> ComplexInfinity}} *) " Jan 29 at 2:42 • The maximum of 1 occurs when \[Rho] is Infinity. Since Infinity is not a number, it cannot be used to define a point ({x, y, \[Rho]}), i.e., there is no point that satisfies the constraints. The maximum is arbitrarily close to 1, i.e., the maximum is 1` in the limit. Jan 29 at 2:53 • Thanks. But, in my case$\rho$is an unknown constant. So, for a given$\rho$, is the maximum$1-\frac{25}{2\rho}\$? Jan 29 at 3:03