Can't get Lagrange multiplier to work in a single exercise

In summary, you can't solve problems involving derivatives of x^3yzb3gh + 37y^38x^3 + k^5x = 0## In summary, you can't solve problems involving derivatives of x^3yzb3gh + 37y^38x^3 + k^5x = 0 because you always end up with unsolvable equations of x^3yzb3gh + 37y^38x^3 + k^5x = 0.
  • #1
Addez123
199
21
Homework Statement
f = x^2 + xy +y^2
x^4 + y^4 <= 8
y => 0
Relevant Equations
Lagrange multiplier
d(f,g)/d(x,y) = 0 also provides equation that solves everything
So I understand the concept of lagrange multiplier but I fail at every single execise I encounter anyways.
Because you always end up with unsolvable equations of x^3yzb3gh + 37y^38x^3 + k^5x = 0

Anways here's my stupid attempt:
Instead of doing
$$grad(f) + \lambda grad(g) = 0$$
I solve
$$
\begin{vmatrix}
df/dx & df/dy \\
dg/dx & dg/dy
\end{vmatrix} = 0$$

$$(2x+y)*4y^3 - (2y+x)(4x^3) = 0$$
$$2xy^3 + y^4 -2x^3y -x^4 = 0$$

At BEST you can deduct y^4 = 8-x^4 from the constraint function g.
But then you're still left with
$$2xy^3 + (8 - x^4) - 2x^3y -x^4 = 0$$
If you substitube y with
$$y = \sqrt{8-x^4}$$
then you just have an extremely convoluted mess.

You could make a guess that (0,0) is a critical point and test it. But really, this is just a mess of numbers and this is where I get stuck on every exercise.
 
Last edited:
Physics news on Phys.org
  • #2
Hello again,
I'm missing a question mark in the problem statement: what is it you want to answer ?
Maximum?Minimum ?

Addez123 said:
Homework Statement:: $$ \begin{align*} & f = x^2 + xy +y^2 \\ & x^4 + y^4 \le 8 \\ & y \ge 0\end{align*} $$

So I understand the concept of lagrange multiplier but I fail at every single execise I encounter anyways.
I sympathize. Always found it hard to wrap my head around the ##\vec\nabla f + \lambda \vec\nabla g = \vec 0 ## and when I believed it again there were these stupid other (*) constraints messing things up.
(*) the ones with < and > in them...

Relevant Equations:: ...
$$ \frac {d(f,g)} {d(x,y)} = 0 \ $$ also provides equation that solves everything
I think I don't believe this last one :rolleyes: . Looks like you are mixing up things.
Care to elucidate 😎 ?

Because you always end up with unsolvable equations of ##x^3yzb3gh + 37y^38x^3 + k^5x = 0##
I get something else , but I suppose you just want to :wink: provide a taste

Anways here's my stupid attempt:
Instead of doing
$$grad(f) + \lambda grad(g) = 0$$ I solve
$$
\begin{vmatrix}
df/dx & df/dy \\
dg/dx & dg/dy
\end{vmatrix} = 0
$$.

Two things:

One:
You sure you need Lagrange ? Because that is about maximizing some ##f## under an equality constraint. Perhaps you can make a case that ##x^4+y^4 = 8## when ##f## is at a maximum, but you have to make that case first.

Two:
Well, the "instead of ... I do" shows that you are a strong believer in derivatives being zero. But you don't explain why you throw away Lagrange.
And you don't explain why you are doing something else. What's the argument ?

Well, three things, actually: A stupid attempt is an attempt too. If nothing else, you can learn from it :wink:

I am with you on the requirement that ##\vec\nabla f = \vec 0## for an extremum if there are no constraints. So I get $$\begin{align*} 2x + y &= 0\\x+2y &= 0 \end{align*}$$a boring minimum at the (0,0) you already found. And no maximum, so we indeed have to investigate the constraint ##x^4+y^4-8=0##. Using Lagrange now. And not the "I do" way but the normal way.

Because in the "I do" way
  • You omit ##\lambda## and
  • solve one equation where you had two:
$$
\begin {bmatrix} \frac{\partial f}{\partial x}\\ \frac{\partial f}{\partial y}\end {bmatrix} +
\lambda\begin {bmatrix} \frac{\partial g}{\partial x}\\ \frac{\partial g}{\partial y}\end {bmatrix} = 0
$$
And this does NOT leave you with one equation, but with three, as it should be. (The third one being the constraint ##x^4+y^4-8=0##). Not easy, but hey, this isn't high school any more.

##\ ##
 
  • Like
Likes Addez123, Mark44 and berkeman
  • #3
The book seem adament on claiming if grad(f) and grad(g) are pararell the functional determinant = 0.
But let's do the lagrange way instead, it's less confusing.

I found critical point (0,0) through grad(f) = 0
Then I put up the expression
$$grad(f) + \lambda grad(g) = 0$$
which gives me 2 more equations (besides grad(f) = 0) to work with:
1)
$$2x+y+\lambda4x^3 = 0$$
2)
$$2y+x+\lambda4x^3 = 0$$

From (1) I deduct (eq.1)
$$y = -2x -\lambda4x^3$$
Insert that into (2) and you get
$$x(3+\lambda4x^2) = 0$$
which mean x1 = 0 or $$(3 + \lambda4x^2) = 0$$

Im abit confused because inserting x = 0 into eq.1 gives y = 0, but inserting x = 0 into g function gives
$$y =2^{3/4}$$
(0, 2^3/4) doesn't check out with (1) so I am not sure what to do with it..

Oh and yes, looking for max, min :p
 
  • #4
Addez123 said:
(besides grad(f) = 0)
No no no ! the gradients are linearly dependent, not zero !
The third equation is ##g=0## i.e. you are on the constraint.
$$2x+y+\lambda4x^3 = 0$$is right. Slight mistake :wink: in$$2y+x+\lambda4x^3 = 0$$ (what is ##\partial g/\partial y ## ?)
Should end up nicely symmetrical in ##x## and ##y## (oh boy, this is really a charming exercise :kiss: !)

Addez123 said:
Oh and yes, looking for max, min :p
Better late than never -- our telepathic capabilities here at PF are extremely good :cool: but not perfect ?:)
So next time include it in the very first paragraph (the so-called "homework statement" :-p )

##\ ##
 
  • #5
Addez123 said:
The book seem adamant on claiming if grad(f) and grad(g) are pararell the functional determinant = 0.
Penny dropped: equation for ##\lambda## can only be solved if that determinant is zero. (Took a while to dawn on me, that :nb)). Still: that's only one necessary condition. ##\vec\nabla f + \lambda \vec\nabla g = \vec 0## gives you two equations. Someone please correct me if I'm talking nonsense here (past bedtime :sleep: ).

##\ ##
 
  • #6
Ahh right! partial y equation was wrong, should be:
$$-3x -\lambda8x^3 + \lambda4y^3 = 0$$
But this gives no useful information, I have neither x^4, or a separate x, or y^4.
Nothing I can use to add into
$$g = x^4 + y^4 -8 = 0$$
that would give any meaningful results..

Also are you saying grad(f) = 0 is not an equation I can use in this context?

And a less relevant question:
People tell me I should write: fx instead of fx' when referring to df/dx..
What am I suppose to use if I am simply referring to the x value of a vector function? When referring to x in f = (x, y)
 
  • #7
Addez123 said:
People tell me I should write: fx instead of fx' when referring to df/dx
Yes. ##f_x## is the partial of f with respect to x. And ##f_x## (or ##\frac{\partial f}{\partial x }##) is better than df/dx, which is the ordinary derivative of a function of one variable.
Addez123 said:
What am I suppose to use if I am simply referring to the x value of a vector function? When referring to x in f = (x, y)
You could say the first coordinate of the vector function.
 
  • #8
From post #1:
f = x^2 + xy +y^2
x^4 + y^4 <= 8
y => 0

@Addez123, are you sure this is the correct problem statement? For one thing, it seems unusual to me that the constraint would be an inequality, not an equation. For another, it wasn't clear for several posts whether you were to maximize f or minimize it. For a third, if there's a typo in the definition of f, that would make for difficulties in working the problem.
 
  • #9
I'm suppose to find max and min value of the function, given the constraints. But I can't edit the primary post anymore :/

There's a typo in the definition of f?
 
  • #10
Addez123 said:
There's a typo in the definition of f?
I don't know -- that's why I'm asking. Is ##f(x, y) = x^2 + xy + y^2## exactly as given in the problem? And is the constraint ##x^4 + y^4 \le 8## or is it ##x^4 + y^4 = 8##?
 
  • #11
Yes that's correct. The constraints are:
##x^4 + y^4 \le 8## and ##y \geq 0##

Is it an impossible to solve equation? yes. Every single exercise is like this, you end up with an convoluted mess that's just purely unsolveable. I've done 3 other exercises, 15 times for 4 days and solved none.
Hate this book, it teaches nothing.
 
  • #12
I've filled in several sheets of paper on the problem in this thread, and so far I don't come up with anything reasonable.

Addez123 said:
I've done 3 other exercises, 15 times for 4 days and solved none.
How about we table this exercise, and see if we can make headway on one or two of your other problems?
 
  • #13
Alright, I'll post the next one but it's basically the same.
 
  • #14
BvU said:
Slight mistake :wink: in ##2y+x+\lambda 4x^3=0 \ ## (what is ##\partial g\over \partial y ## ?)
Addez123 said:
Ahh right! partial y equation was wrong, should be:$$
−3x−\lambda 8x^3+\lambda 4y^3=0$$
Agree: should have been ##2y+x+\lambda 4####y####^3=0 \ ## but (as usual :wink: ?) you take an extra step...

I am going so much slower and am looking at $$ \begin {cases}
2x+y+4\lambda x^3 & = 0 \\
x+2y+4\lambda y^3 & = 0 \\
x^4+y^4 & = 8 \end {cases}$$where I notice this set is symmetrical wrt ##x## and ##y##. That's so nice I already mentioned it in #4. Because I'm also completely useless when third and fourth powers appear in equations.

It means that if you solved the whole lot and marked the solutions on a graph, the picture remains unchanged when you swap the ##x## and ##y## axes. In short: the lines ##x-y=0## and ##x+y=0## seem interesting. Sure enough, on ##x-y=0## we have ##f = 3x^2## and on ##x+y=0## we have ##f = x^2##. Hmmm...

One of the reasons it took me a while to put this post together (several sheets of paper too :smile: ) Is that I had to dust off and mobilize some very old but solid knowledge:​
If we do a coordinate transform (rotate the ##x## and ##y## axes over ##\pi/4## :​
[edit]##\LaTeX## fumbling in progress :cry: Solution: the automated BB INDENT stuff is in the way ?: And it comes back everytime I insert e.g. a blank line ?:)
$$\begin{bmatrix} x'\\ y'\end {bmatrix} = \begin{bmatrix} {\frac 1 2 \sqrt 2 x} & {\frac 1 2 \sqrt 2 y} \\{-\frac 1 2 \sqrt 2 x} & {\frac 1 2 \sqrt 2 y} \end {bmatrix} \Rightarrow
\begin{bmatrix} x\\ y\end {bmatrix} = \begin{bmatrix} {\frac 1 2 \sqrt 2 x'} & {-\frac 1 2 \sqrt 2 y'} \\{\frac 1 2 \sqrt 2 x'} & {\frac 1 2 \sqrt 2 y'} \end {bmatrix} $$​
then​
$$x^2+xy+y^2 = \frac 3 2 x'^2 +\frac 1 2 y'^2 $$ (all that paper ... ) so we have a contour plot of ellipses, stretched in the ##y'## direction.​
The graph of ##x^4 + y^4## is a deformed circle ("kurtosed" might be a nice term :smile: but a short search yields a superellipse or Lamé curve with the name Squircle -- How I love the internet :kiss: ) :​
1640123675923.png
( picture courtesy of https://www.mathway.com/Algebra)​

So we are tempted to declare the intersections of this squircle and ##x-y = 0## as the top value winners of our maximum search !​

Not really a case of straight ahead equation solving ! One could say: Much better with mix and match !​
Of course a despicable cheater would leave all the work to the internet and get an answer too ... including the rotated ellipses and the squircle and ...​
This was real fun ! Look forward to the next one :cool:
@Mark44 : you are a mentor and are entitled to erase all this blabla because it transgresses the PF full solution ban. If you really have to, please save me the source text somewhere.​
##\ ##​
 
Last edited:
  • Like
Likes Addez123
  • #15
Now that's a lot of math!

I can see that x and y are "interchangeable" and thus symmetrical, I have no idea why we would rotate the whole thing 90 degrees or why that would even change anything.
Even so I have no idea how the final equation of a kurtose would make anything easier. Now you got 2 unknown variables and their derivatives to work with. Even worse!

It's really cool solution though, did you get the answer:
##max: (\sqrt{2}, \sqrt{2}) = 6, min (0,0) = 0##?
 
  • #16
And after a good nights sleep I feel a little less smug. After all this advertising Lagrange and then not finding an honest way to find e.g. ##\lambda## (why ##-\frac 3 8 ## ?), I share the nagging feeling in #11 and #12.

But it was fun, and perhaps the next one is more forgiving :wink: ?

---

Back to business and loose ends:
Addez123 said:
Also are you saying grad(f) = 0 is not an equation I can use in this context?
Correct ! With the story attached already told:

BvU said:
I am with you on the requirement that ##\vec\nabla f = \vec 0## for an extremum if there are no constraints.
And for this exercise ##f## only has one single extremum and that's a minimum.

Therefore any possible maximum within the (inequality) constraint must be on the constraint and then we have the Lagrange conditions. A simple check shows that ##f > 0## somewhere within the constraints, so there is a maximum > 0 and it is at a point where necessarily ##\vec\nabla f \ne \vec 0##​

So the answer to your question is : ##\vec\nabla f = \vec 0## is useful in this context, but only for the purpose of showing that it can't be used to find the desired answer and that something else is needed. :smile:

##\ ##
 
  • #17
Addez123 said:
I have no idea why we would rotate the whole thing 90 degrees or why that would even change anything.
Good point. Useless showing off :woot:. Put it down to vanity. Or stubbornness: I wanted to see these ellipses emerge or else I wouldn't be able to sleep :-p.

Even so I have no idea how the final equation of a kurtose would make anything easier. Now you got 2 unknown variables and their derivatives to work with. Even worse!
I disagree: once I can see the ellipses I know I want te be on the short axis and as far away from the origin as possible to get a maximum, so on ##x = y## and there ##2x^4=8## gets me, you and wolfram the same answer:
##max: (\sqrt{2}, \sqrt{2}) = 6, min (0,0) = 0##?

A cool solution, indeed :cool: !
Nevertheless, someone showing all of us a decent analytical way to actually find these ##\lambda## will earn my everlasting gratitude !

Homework (easy!) for you:
  • show us ##\vec\nabla f## and ##\vec\nabla g## at these maxima and see that they are collinear :wink: indeed.
  • same for the other two local maxima

##\ ##
 

1. Why is the Lagrange multiplier not working in my exercise?

The Lagrange multiplier may not be working due to a few possible reasons. One common reason is that the constraints in the problem may not be properly defined. Another reason could be that the optimization problem does not meet the necessary conditions for the Lagrange multiplier to be applicable. Additionally, there may be errors in the mathematical calculations or coding of the problem.

2. How do I know if the Lagrange multiplier is applicable to my problem?

The Lagrange multiplier is applicable to optimization problems where the objective function and constraints are differentiable. Additionally, the constraints must be independent and not linearly dependent. If these conditions are met, then the Lagrange multiplier can be used to solve the problem.

3. Can I use the Lagrange multiplier for non-linear optimization problems?

Yes, the Lagrange multiplier can be used for non-linear optimization problems as long as the necessary conditions are met. However, the calculations may become more complex and may require numerical methods to solve.

4. How do I calculate the Lagrange multiplier?

The Lagrange multiplier can be calculated by setting up the Lagrangian function, which is the objective function plus the product of the Lagrange multiplier and the constraints. The Lagrange multiplier can then be found by taking the partial derivative of the Lagrangian function with respect to the variable being optimized and setting it equal to zero.

5. Are there any alternative methods to the Lagrange multiplier for solving optimization problems?

Yes, there are alternative methods such as the KKT conditions and the method of undetermined multipliers. These methods may be more suitable for certain types of optimization problems, so it is important to understand the differences and limitations of each method before choosing one to use.

Similar threads

  • Calculus and Beyond Homework Help
Replies
8
Views
467
  • Calculus and Beyond Homework Help
Replies
6
Views
849
  • Calculus and Beyond Homework Help
Replies
9
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
540
  • Calculus and Beyond Homework Help
Replies
25
Views
337
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
10
Views
436
  • Calculus and Beyond Homework Help
Replies
2
Views
730
  • Calculus and Beyond Homework Help
Replies
4
Views
834
  • Calculus and Beyond Homework Help
Replies
15
Views
1K
Back
Top