Well I am new to Mathematica and got really stuck solving this problem.
In class, I was ask to use the Lagrange multiplier method to find the maximum and minimum value of $f(x,y) = x^2+y^2$ which lies on the curve $x^4 + 4xy + 2y^4 = 8$
What I did was
F[x_, y_] := x^2 + y^2
G[x_, y_] := x^4 + 4 x y + 2 y^4 - 8
gradf = {D[F[x, y], x], D[F[x, y], y]};
gradg = {D[G[x, y], x], D[G[x, y], y]};
Print["grad f = ", gradf]
output = grad f = {2 x,2 y}
Print["grad g = ", gradg]
output = grad g = {4 x^3+4 y,4 x+8 y^3}
Solve[{gradf[x, y] == lambda gradg[x, y], g[x, y] == 8}, {x, y, lambda}]
Then after this part I keep getting an error message or some ridiculous infinite number.
gradf
andgradf[x, y]
are not the same thing as far as Mathematica is concerned (you use these inconsistently); (2)G[x, y]
andg[x, y]
are not interchangeable (you define the former and then use the latter inSolve
); (3) it's generally best practice to avoid defining capitalized variables, as they can't conflict with Mathematica's own predefined functions; (4) youroutput
statements don't actually do anything. $\endgroup$