Skip to main content
19-Tanzanite
May 10, 2023
Solved

How to find Global Maximum, Global Minimum, Local Maximum and Local Minimum of a function?

  • May 10, 2023
  • 3 replies
  • 10687 views

Hello,

Considering the following function:

CornelBejan_1-1683700759179.png

CornelBejan_2-1683700770965.png

How to find: 

  • Local Maximum: x1 and f(x1)
  • Local Minimum: x2 and f(x2)
  • Global Maximum: x3 and f(x3)
  • Global Minimum: x4 and f(x4)

on the interval of x:

CornelBejan_7-1683702113827.png

CornelBejan_6-1683702095867.png

 

 

Mathcad Prime 8 file attached.

 

Thank you.

 

Best answer by Werner_E

You could do as Luc suggested, but the symbolic engine (or its interface) is not capable enough to give you all needed solutions. "assume" and "fully" are ignored and just one solution is returned.

Werner_E_2-1683718759980.png

It should work that way, but only does for simpler functions where Primes symbolic has not to switch to its float mode.

EDIT: It works for simpler functions, but we should omit "fully"!

Werner_E_3-1683719354965.png

 

 

So in your case you may resort to numeric methods like the "root" function:

Werner_E_0-1683718076314.png

You may also try a utility function like the one below, but it sure won't work for all type of functions.

Werner_E_1-1683718598441.png

 

To distinguish between maxima and minima, the second derivative can be used:

Werner_E_0-1683718397462.png

Attached file is in P9 format

 

3 replies

23-Emerald IV
May 10, 2023

Take the derivative of f to x, f'(x). Solve f'(x)=0. That should give you (at least) 4 roots. Calculate f(x) for each of these roots and determine from their values which one is global or local, max or min.

 

Success!

Luc

Cornel19-TanzaniteAuthor
19-Tanzanite
May 10, 2023

CornelBejan_2-1683716557498.png
CornelBejan_0-1683716427323.png

So, only one root the derivative of f(x) wants to give to us (at least in Mathcad Prime (8)).

CornelBejan_3-1683716710903.png

CornelBejan_4-1683716762571.png

 

 

 

ttokoro
21-Topaz I
21-Topaz I
May 10, 2023

Using digital sampling data.

image.png

t.t.
Werner_E25-Diamond IAnswer
25-Diamond I
May 10, 2023

You could do as Luc suggested, but the symbolic engine (or its interface) is not capable enough to give you all needed solutions. "assume" and "fully" are ignored and just one solution is returned.

Werner_E_2-1683718759980.png

It should work that way, but only does for simpler functions where Primes symbolic has not to switch to its float mode.

EDIT: It works for simpler functions, but we should omit "fully"!

Werner_E_3-1683719354965.png

 

 

So in your case you may resort to numeric methods like the "root" function:

Werner_E_0-1683718076314.png

You may also try a utility function like the one below, but it sure won't work for all type of functions.

Werner_E_1-1683718598441.png

 

To distinguish between maxima and minima, the second derivative can be used:

Werner_E_0-1683718397462.png

Attached file is in P9 format

 

Cornel19-TanzaniteAuthor
19-Tanzanite
May 10, 2023

I thought about root, but in the root it must be specified an initial guess of each individual root. And this it is something like that per guess. Now, of course, with the graph in front of our eyes the things are much easier to guess each initial guess root. I do not like pretty much this variant with guessing the solutions...
I know that in Mathcad15 there is a function by which the solution is found by giving an interval. Is it possible something like that also in Mathcad Prime?

25-Diamond I
May 10, 2023

@Cornel wrote:

I thought about root, but in the root it must be specified an initial guess of each individual root. And this it is something like that per guess. Now, of course, with the graph in front of our eyes the things are much easier to guess each initial guess root. I do not like pretty much this variant with guessing the solutions...


That exactly was the reason why I quickly wrote the utility function "Extrema()". Look it up in my answer above. You specify the function and the interval and it returns the extrema. Its a function which sure would require some additional work to deal with the situation when one of the x-values used by chance IS exactly an extreme position or to deal with discontinuities, etc. But the function provided could be a starting point for your own attempts.

 


I know that in Mathcad15 there is a function by which the solution is found by giving an interval.

I don't know what you are talking about!? Are you talking of a built-in function? Which one?

Maybe you confuse it with "localmin()" and "localmax()". These functions are still available in Prime, too, but they don't work for functions but rather only for sampled data vectors, as ttokoro already has shown, and they also have their own numeric limitations.

I know that in the past questions about finding all zeros of a function in a given interval came up here in the forum quite often and me an others may have provided some kind of utility functions, don't remember. They sure all had their limits and drawbacks, though. You may search the forum, maybe you can find something you like.