The minimize command finds the smallest value of an expression, possibly restricted to a specific domain.
The domain must be closed and bounded and obj must be continuous in every point of it, otherwise the final result may be incorrect or meaningless. If the minimal value could not be obtained, undef is returned.
The maximize command takes the same parameters as minimize, but returns the global maximum of obj on the specified domain.
Examples.
sin | ⎛ ⎝ | 4 | ⎞ ⎠ |
− |
|
⎡ ⎢ ⎢ ⎣ | − |
| , | ⎡ ⎢ ⎢ ⎣ |
| ,− |
| ⎤ ⎥ ⎥ ⎦ | ⎤ ⎥ ⎥ ⎦ |
−2 |
0 |
⎡ ⎢ ⎢ ⎣ | − | √ |
| , | ⎡ ⎢ ⎢ ⎣ |
| π , |
| π , |
| π | ⎤ ⎥ ⎥ ⎦ | ⎤ ⎥ ⎥ ⎦ |
⎡ ⎣ | −1, | ⎡ ⎣ |
| ⎤ ⎦ | ⎤ ⎦ |
obj:=sqrt(x^2+y^2)-z; |
constr:=[x^2+y^2<=16,x+y+z=10]; |
minimize(obj,constr,[x,y,z]) |
−4 | √ |
| −6 |
−4 |
cos | ⎛ ⎝ | 1 | ⎞ ⎠ |
obj:=piecewise(x<=-2,x+6,x<=1,x^2,3/2-x/2); |
maximize(obj,x=-3..2) |
4 |
|
⎡ ⎢ ⎢ ⎣ |
| √ |
| , | ⎡ ⎢ ⎢ ⎣ |
| ⎤ ⎥ ⎥ ⎦ | ⎤ ⎥ ⎥ ⎦ |
|
assume(a>0); |
maximize(x^2*y^2*z^2,x^2+y^2+z^2=a^2,[x,y,z]) |
|