Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the maximum and minimum of a function using Maxima?

Tags:

maxima

I have trying to find a way to obtain the maximum and the minimum value of a function using Maxima (wxMaxima), but until now I have not found how to do it.

Could you please tell me how would you do it?

For example, suppose I have the following code:

f(x) := (3*x)/(x^2 - 2*x + 4);

And then I plot this function in the range -10, 10, and I obtain:

enter image description here

I know that the maximum is 3/2 and the minimum should be -1/2.

like image 553
nbro Avatar asked Apr 17 '15 18:04

nbro


People also ask

How do you find the maximum value of a maxima and minima?

First Order Derivative TestIf f'(x) changes sign from positive to negative as x increases through point c, then c is the point of local maxima. And the f(c) is the maximum value. 2. If f'(x) changes sign from negative to positive as x increases through point c, then c is the point of local minima.

How do you find the maxima and minima of a function on an interval?

Here, the maximum value f(x) at x = 1 is called the absolute maximum value, global maximum or greatest value of the function f on the closed interval [0, 1]. Similarly, the minimum value of f(x) at x = 0 is called the absolute minimum value, global minimum or least value of the function f on the closed interval [0, 1].

What is minima and maxima of a function?

Maxima and minima of a function are the largest and smallest value of the function respectively either within a given range or on the entire domain. Collectively they are also known as extrema of the function. The maxima and minima are the respective plurals of maximum and minimum of a function.

Is maxima and maximum the same?

In mathematical analysis, the maxima and minima (the respective plurals of maximum and minimum) of a function, known collectively as extrema (the plural of extremum), are the largest and smallest value of the function, either within a given range (the local or relative extrema), or on the entire domain (the global or ...


3 Answers

My advice is to find the extreme values the same way you would do it by hand: compute the derivative, solve for derivative = 0, and substitute any values found back into the original function. E.g.:

(%i1) f(x) := (3*x)/(x^2 - 2*x + 4);
                                         3 x
(%o1)                        f(x) := ------------
                                      2
                                     x  - 2 x + 4
(%i2) diff (f(x), x);
                             3          3 x (2 x - 2)
(%o2)                   ------------ - ---------------
                         2               2           2
                        x  - 2 x + 4   (x  - 2 x + 4)
(%i3) ratsimp (%);
                                       2
                                    3 x  - 12
(%o3)                   - -----------------------------
                           4      3       2
                          x  - 4 x  + 12 x  - 16 x + 16
(%i4) num (%);
                                           2
(%o4)                              12 - 3 x
(%i5) solve (%, x);
(%o5)                          [x = - 2, x = 2]
(%i6) map (lambda ([e], subst (e, f(x))), %);
                                      1  3
(%o6)                              [- -, -]
                                      2  2

If I were being careful, I would have verified that x = -2 and x = 2 are indeed extreme values and not just inflection points, and I would have verified that the denominator of %o3 is nonzero at x = -2 and x = 2 before trying to evaluate f(x) at those points.

like image 113
Robert Dodier Avatar answered Oct 05 '22 06:10

Robert Dodier


Use the function lbfgs like this :

lbfgs(-f(x), [x], [1.0], 1e-4, [-1,0]);

The code above gives the position [x = 2] of the maximum of the function.

like image 33
wimmer Avatar answered Oct 05 '22 06:10

wimmer


enter image description here

Identify when the derivative is increasing or decreasing

like image 38
nightcrawler Avatar answered Oct 05 '22 05:10

nightcrawler