How do I find the Critical points of a multi-variable function using MATlab?

In summary, the conversation is about finding critical points of a two-variable function using MATlab. The function in question is f(x,y) = 10x^2y - 5x^2 - 4y^2 - x^4 -2y^4, which is supposed to have six potential critical points. The person has provided the equations f_x = 20yx - 10x - 4x^3 and f_y = 10x^2 - 8y - 8y^3, and has attempted to solve for the potential critical points. They are unsure if their solution is correct and are asking for help on how to check with MATlab. They are also wondering if using symbolic variables
  • #1
VinnyCee
489
0
How do I find the Critical points of a two-variable function using MATlab?

I have a problem, I cannot seem to find the critical points of a two-variable function for the life of me!

The funtion [tex]f(x,y) = 10x^2y - 5x^2 - 4y^2 - x^4 -2y^4[/tex] is supposed to have six potential critical points. I have the following:

[tex]f_x = 20yx - 10x - 4x^3[/tex]
[tex]f_y = 10x^2 - 8y - 8y^3[/tex]

For what it's worth:

[tex]\nabla f_x = (20y - 10 - 12x^2) i + (20x) j[/tex]
[tex]\nabla f_y = (20x) i + (-8-24y^2) j[/tex]

[tex]\nabla f_x = \lambda\nabla f_y[/tex]

[tex]\lambda = \frac{20y - 10 - 12x^2}{20x} = \frac{20x}{-8-24y^2}[/tex]

I know that the potential critical points are at [tex]f_x = f_y = 0[/tex], but how do I find these using MATlab, or even on paper. How would I solve for both equations?

I just can't crack this problem!

P.S. - I have MATlab version 6.5
 
Last edited:
Physics news on Phys.org
  • #2
Here are some preliminary (probably wrong) answers:

Ok, I took the first equation [tex]f_x = 20yx - 10x - 4x^3 = 0[/tex] and factored out a [tex]2x[/tex] to get [tex]2x (10y - 5 - 2x^2) = 0[/tex].

Then I solved for [tex]-2x^2[/tex] to get [tex]-2x^2 = 5 - 10y[/tex] and I substituted that into the second equation of [tex]f_y = 10x^2 - 8y - 8y^3 = 0[/tex] to get [tex]f_y = -5(5 - 10y) - 8y - 8y^3[/tex]. This resolves down to [tex]-8y^3 + 42y = 25[/tex] which one can solve and get [tex]y = 1.898, 0.647, -2.545[/tex], but what do I do now?
 
Last edited:
  • #3
Using the supposed answers, I figured this:

Plug this [tex]y = 1.898, 0.647, -2.545[/tex] into [tex]f_x = 20yx - 10x - 4x^3[/tex] to get [tex]x = \pm 2.644, \pm 0.857, 0[/tex]

Are these correct? When the [tex](x, y)[/tex]'s are plugged into [tex]f_x[/tex] and [tex]f_y[/tex] they are pretty close to zero (rounding). But for some reason I don't think this is correct. How would I check with MATlab?
 
  • #4
This may not be any help but ...

have you tried creating symbolic variables for x and y?

try:
>syms x y
>g=((10*x^2)*y)-(5*x^2)-(4*y^2)-(x^4)-(2*y^4)
and then solve for g
(I would have tyied this before posting but my MATlab has a bug and willl not recognise the syms command!)
 
Last edited:

1. How do I input a multi-variable function into MATLAB?

To input a multi-variable function into MATLAB, you can use the "syms" function to define symbolic variables and then use them to create your function. For example, "syms x y z" will define the variables x, y, and z, and then you can use them to create your function, such as "f = x^2 + y^2 + z^2".

2. What is the syntax for finding the critical points of a multi-variable function in MATLAB?

The syntax for finding the critical points of a multi-variable function in MATLAB is "syms x y z" to define the variables, "f = x^2 + y^2 + z^2" to create the function, and then "solve([diff(f,x)==0, diff(f,y)==0, diff(f,z)==0], [x,y,z])" to solve for the critical points.

3. Can I find the critical points of a multi-variable function using MATLAB's built-in functions?

Yes, MATLAB has built-in functions that can help you find the critical points of a multi-variable function. One example is the "fmincon" function, which can be used to find the minimum or maximum of a function subject to constraints. By setting the constraints to be the first partial derivatives of the function equal to 0, you can find the critical points.

4. What if my multi-variable function has more than three variables?

If your multi-variable function has more than three variables, you can still use MATLAB to find the critical points. The syntax will be similar to the one for three variables, but you will need to include additional equations for each partial derivative with respect to the extra variables.

5. Are there any other ways to find the critical points of a multi-variable function in MATLAB?

Yes, there are other ways to find the critical points of a multi-variable function in MATLAB. One alternative is to use the "fsolve" function, which can be used to find the roots of a system of equations. By setting the system of equations to be the partial derivatives of the function equal to 0, you can find the critical points.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
995
  • Calculus and Beyond Homework Help
Replies
4
Views
2K
Replies
1
Views
1K
  • Calculus
Replies
1
Views
1K
Replies
1
Views
832
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
Replies
3
Views
1K
  • Calculus and Beyond Homework Help
Replies
4
Views
835
Back
Top