Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mathematica - Maximizing a Function Over an Interval

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.

like image 714
nick_name Avatar asked Sep 10 '25 23:09

nick_name


1 Answers

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.

like image 135
rcollyer Avatar answered Sep 13 '25 16:09

rcollyer