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:
I know that the maximum is 3/2 and the minimum should be -1/2.
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.
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].
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.
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 ...
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.
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.
Identify when the derivative is increasing or decreasing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With