# HP Forums

Full Version: Find minimum or maximum of multi-variable function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm not sure whether there is a function or command which can find the minimum or maximum of multi-variable function e.g

find min of Sqrt((x-14)^2 + (y-55)^2) + Sqrt((x-23)^2 + (y-95)^2)

Or any application which can help finding this kind of problem?
(08-28-2019 07:14 AM)teerasak Wrote: [ -> ]I'm not sure whether there is a function or command which can find the minimum or maximum of multi-variable function e.g.

find min of Sqrt((x-14)^2 + (y-55)^2) + Sqrt((x-23)^2 + (y-95)^2)

Or any application which can help finding this kind of problem?

This is a multivariate calculus problem with the function f(x,y) = z, where z is the unstated dependent variable for the equation you gave for the third z-axis. Fortunately your two independent variables, x and y, aren't completely jumbled together. Conceptually it's the same approach as univariate calculus. The zeroes of the first partial derivatives will help identify maxima, minima, and saddle points, if there are any, where the slope of the tangent plane is zero. This involves finding partial derivatives of f(x,y) as part of the solution and it sets up a partial derivative vector called the gradient. A gradient is the same concept as a slope in three (or more) dimensions as a plane (in three dimensions) or a hyper-plane in four or more dimensions. When the set of all (x,y) are found that are zeroes of both the partial derivatives with respect to both x and y, it's called the set of zero vectors. Among them should be (if they exist) the global maximum, the global minimum, other local maxima, other local minima, and a phenomenon not found in univariate calculus, saddle points. Local maxima are other hilltops not as tall as the tallest peak in the mountain range. A saddle point looks like a saddle, and it's the low spot between two or more peaks that rises in their direction and falls off in the directions between the peaks.

See this video from the Kahn Academy and its follow-on videos to give you a conceptual idea of what you'll need to do . . .

With regard to the HP Prime, look for the Gradient tools in its derivative calculus toolbox. Hope this helps get you started. The conceptual aspect of what you want to do is well over half the battle. You'll undoubtedly have to poke around a bit to find what you need to use and how to use it in the calculator. Looked for some things in the Prime documentation which isn't as helpful as it could be. Been decades since I did this stuff. All we had was pencils, engineering pads, a slide rule, and the CAS calculator was the CRC Handbook of Mathematical Tables (which has sections on derivatives and integrals). :-D

BTW, don't think of math involving three or more independent variables in hyperspaces as being that exotic. There are a multitude of practical applications for it in maximizing or minimizing aspects of physical processes and systems with multiple inputs or controls when responses are non-linear.

John
This is the sum of distances of M(x,y) to 2 points A(14,55) and B(23,95). Therefore the min is any point in the segment AB. Multivariate calculus would fail here, because the minimum is not isolated (the gradient is 0 in the segment).
If you plot the equation n the 3D app:

sqrt((X-14)^2+(Y-55)^2)+sqrt((X-23)^2+(Y-95)^2)

Tap Menu/Zoom/Out 4 or 5 times, then go to the plot setup the new Zoom values are not saved. Is there a way to use Menu/Zoom/Out and have the zoom settings saved in Xmin, Xmax, Ymin, Ymax, Zmin, and Zmax?

@jlind, Thank you. It is time to come back to review multi-variable calculus which has gone from my head. Thank you for the info and link.

@parissee, you are right. So the minimum for this case is the distance between two point, which is 41. However, I’m not sure, in HP prime, is there the command to find Min/max of multi-variable function? One tools I use is 3D graph. It helps but quite difficult to read the value, and no tools to find extremum in the graph.

@roadrunner, I faced the same issue too. For this problem, I zoom out few time to see the 3D graph. After I quit from the plot, and come back, the scale go back to default.
I tried to find derivative of the function to x and to y, and use solve command to find the value x, and y to make the derivative to zero, as in the pictures.

I got strange calculation result c_0. What does it mean? I try to evaluate it numerically, it still leave c_0 as the result.
(08-29-2019 07:19 PM)teerasak Wrote: [ -> ]So the minimum for this case is the distance between two point, which is 41.

Just put a third point and you will jump to the complex problems world. If you interested, here you can find a sloooow solution on a TI-83:

Csaba
(08-29-2019 07:19 PM)teerasak Wrote: [ -> ]@parissee, you are right. So the minimum for this case is the distance between two point, which is 41. However, I’m not sure, in HP prime, is there the command to find Min/max of multi-variable function? One tools I use is 3D graph. It helps but quite difficult to read the value, and no tools to find extremum in the graph.

There is an extrema command in Xcas to do that, but it seems it is not available in the Prime CAS.
@parisse , that's really unfortunate for not having that command. So need to find out from derivative and solve equation. Thank you for information.
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :