I have a function which I would like to maximize over an independent variable range, say a->b. How would I do this in Mathematica? The documentation does not provide an answer.
The functions you are looking for are Maximize
and NMaximize
(similarly, there is Minimize
and NMinimize
). Since you do not provide any details about the function itself, I shall call it f
and assume that it takes one variable. Then to maximize over a given range, you specify both the function and the range, as follows
Maximize[{ f[x], a <= x <= b}, x]
or, if symbolic maximization is difficult to do, you can have it numerically maximized using the same form
NMaximize[{ f[x], a <= x <= b}, x]
For minimization, replace as appropriate.
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