 minimize examples - Maple Help

Home : Support : Online Help : Mathematics : Optimization : minimize examples

A Demonstration of the Procedure minimize

The procedure minimize returns the infimum of an expression or function over a given domain.  It is also possible to have minimize return both the infimum and the location where the infimum is either approached or achieved.

 > $\mathrm{restart}$ The Infimum of a Function

A function $f$ on a given domain D is said to be bounded below on D if there exists a real number $\mathrm{\beta }$ such that $\mathrm{\beta }\le f\left(x\right)$ for each $x$ in D.  If such a $\mathrm{\beta }$ exists then it is called a lower bound of $f$ on $\mathrm{D}$.  For example, the function cosh(x) is bounded below by 0, (or any other number less than or equal to 1.)

 > $\mathrm{plot}\left(\mathrm{cosh}\left(x\right),x=-3..3,y=-1..5\right)$ If a function $f$ is bounded below on a domain D and if there exists an alpha which is a lower bound of f on D with the additional property that for any other lower bound gamma it follows that $\mathrm{\gamma }\le \mathrm{\alpha }$ then alpha is said to be the infimum of the function $f$ on D.  For example, the infimum of the function $\mathrm{cosh}\left(x\right)$ over the real line is 1.  Another example is the function ${ⅇ}^{x}$ on the real line which has an infimum of 0 but there does not exist a real number $x$ such that ${ⅇ}^{x}=0$.

 > $\mathrm{plot}\left({ⅇ}^{x},x=-5..2\right)$ If a function is not bounded below then the infimum is said to be $-\infty$.  For example, the infimum of $\mathrm{tan}\left(x\right)$ on the interval -5..5 is $-\infty$:

 > $\mathrm{plot}\left(\mathrm{tan}\left(x\right),x=-5..5,y=-10..10,'\mathrm{discont}=\mathrm{true}'\right)$  An Example of Finding the Infimum Analytically

As an example, we will prove that the infimum of $\mathrm{cosh}\left(x\right)$ on the real line is 1.

$\mathrm{cosh}\left(0\right)=1$ and therefore 1 is a lower bound.  Differentiating $\mathrm{cosh}\left(x\right)$ with respect to $x$, we get

 > $\frac{ⅆ}{ⅆx}\mathrm{cosh}\left(x\right)$
 ${\mathrm{sinh}}{}\left({x}\right)$ (1.1.1)

which is a function which is strictly greater than zero for and strictly less than zero for $x>0$. Proof Using the Mean Value Theorem The mean value theorem states that for two values x and y where $x, there exists some value c in the open interval (x,y) such that             $f\left(y\right)-f\left(x\right)=\left(\genfrac{}{}{0}{}{\frac{ⅆ}{ⅆx}f\left(x\right)}{\phantom{x=c}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}|\phantom{\rule[-0.0ex]{0.1em}{0.0ex}}\genfrac{}{}{0}{}{\phantom{\frac{ⅆ}{ⅆx}f\left(x\right)}}{x=c}\right)\left(y-x\right)$ . In this case, if we assume y>0 this gives us that $\mathrm{cosh}\left(y\right)-\mathrm{cosh}\left(0\right)=\mathrm{sinh}\left(c\right)y$ for some value c in the open interval (0,y).  Therefore c>0 and thus $0<\mathrm{sinh}\left(c\right)$ and so therefore $0<\mathrm{cosh}\left(y\right)-1$.  A similar argument gives us the same result when $y<0$.  Therefore the infimum of $\mathrm{cosh}\left(x\right)$ is 1.
 > $\mathrm{minimize}\left(\mathrm{cosh}\left(x\right),x=-\mathrm{∞}..\mathrm{∞}\right)$
 ${1}$ (1.1.2)

The user may wish to try this technique with a simpler function such as ${x}^{2}$. Specifying the Domain of a Variable

The domain of a variable can be specified in one of three ways: The Default minimize( f(x), x )

If just the variable is listed, then it is assumed that that variable is to be minimized over the entire real line, that is, $-\infty ..\infty$.

 > $\mathrm{minimize}\left(\mathrm{sin}\left(x\right)\right)$
 ${-1}$ (2.1.1) A Range minimize( f(x), x = 0..1 )

If the variable is equated to a range, then the variable is minimized over the closed interval bounded by the given range.  The endpoints of the range must be of type realcons.

 > $\mathrm{minimize}\left(\mathrm{sin}\left(x\right),x=0..4\right)$
 ${\mathrm{sin}}{}\left({4}\right)$ (2.2.1)

This form of specifying the domain over which the function is to be minimized allows a quick substitution to give a plot of the function:

 > $\mathrm{minimize}\left({x}^{2}-xy+2{y}^{2}+{ⅇ}^{x},x=-1..0,y=-\frac{1}{2}..\frac{1}{2}\right)$
 $\frac{{7}{}{{\mathrm{LambertW}}{}\left(\frac{{4}}{{7}}\right)}^{{2}}}{{8}}{+}{{ⅇ}}^{{-}{\mathrm{LambertW}}{}\left(\frac{{4}}{{7}}\right)}$ (2.2.2)
 > $\mathrm{evalf}\left(\right)$
 ${0.8101382722}$ (2.2.3)
 > $\mathrm{plot3d}\left({x}^{2}-xy+2{y}^{2}+{ⅇ}^{x},x=-1..0,y=-\frac{1}{2}..\frac{1}{2},'\mathrm{axes}=\mathrm{framed}'\right)$  A Simple Relation minimize( f(x), x > 0 )

A domain can be specified by having a name related to an object of type realcons by one of the relation operators =, <, <=, > or >=.  Some examples are:

 > $\mathrm{minimize}\left(\mathrm{cosh}\left(x\right),x=5\right)$
 ${\mathrm{cosh}}{}\left({5}\right)$ (2.3.1)
 > $\mathrm{minimize}\left({x}^{2},5
 ${25}$ (2.3.2)
 > $\mathrm{minimize}\left(\mathrm{sin}\left(x\right),x<3\right)$
 ${-1}$ (2.3.3)
 > $\mathrm{minimize}\left(\mathrm{signum}\left(x\right),0
 ${1}$ (2.3.4)
 > $\mathrm{minimize}\left(\mathrm{signum}\left(x\right),0\le x\right)$
 ${1}$ (2.3.5)

If no domains are given for any variable then it is assumed that each indeterminate of type name is being minimized over the entire real line:

 > $\mathrm{minimize}\left({x}^{2}+\mathrm{cosh}\left(y\right)+3\right)$
 ${4}$ (2.1)
 > $\mathrm{minimize}\left({x}^{2}+\mathrm{cosh}\left(y\right)+3,x=-\mathrm{∞}..\mathrm{∞},y=-\mathrm{∞}..\mathrm{∞}\right)$
 ${4}$ (2.2)
 > $\mathrm{minimize}\left({x}^{2}+\mathrm{cosh}\left(y\right)+3,x=-\mathrm{∞}..\mathrm{∞}\right)$
 ${3}{+}{\mathrm{cosh}}{}\left({y}\right)$ (2.3)
 > $\mathrm{plot3d}\left({x}^{2}+\mathrm{cosh}\left(y\right)+3,x=-5..5,y=-5..5,'\mathrm{axes}=\mathrm{framed}'\right)$  Option location

If the option location or location=true is given, then an expression sequence of two objects is returned, the first being the infimum and the second is a set of lists where the first operand of each list is a list of substitutions which indicates a point or set of points at or near which the infimum is either approached or achieved.  Four examples are:

 > $\mathrm{minimize}\left({x}^{2},x=-3..3,'\mathrm{location}'\right)$
 ${0}{,}\left\{\left[\left\{{x}{=}{0}\right\}{,}{0}\right]\right\}$ (3.1)
 > $\mathrm{minimize}\left(\mathrm{cosh}\left(x\right),x=-3..3,'\mathrm{location}'\right)$
 ${1}{,}\left\{\left[\left\{{x}{=}{0}\right\}{,}{1}\right]\right\}$ (3.2)
 > $\mathrm{minimize}\left({\left({x}^{2}-2\right)}^{2},x=-4..4,'\mathrm{location}'\right)$
 ${0}{,}\left\{\left[\left\{{x}{=}\sqrt{{2}}\right\}{,}{0}\right]{,}\left[\left\{{x}{=}{-}\sqrt{{2}}\right\}{,}{0}\right]\right\}$ (3.3)
 > $\mathrm{minimize}\left(\mathrm{sin}\left(x\right),x=2..12,'\mathrm{location}'\right)$
 ${-1}{,}\left\{\left[\left\{{x}{=}\frac{{3}{}{\mathrm{\pi }}}{{2}}\right\}{,}{-1}\right]{,}\left[\left\{{x}{=}\frac{{7}{}{\mathrm{\pi }}}{{2}}\right\}{,}{-1}\right]\right\}$ (3.4)

In some cases, minimize cannot determine the location and therefore returns FAIL as the location.

 > $\mathrm{minimize}\left(\mathrm{signum}\left(\mathrm{cosh}\left(x\right)-3\right),x=1..3,'\mathrm{location}'\right)$
 ${-1}{,}{\varnothing }$ (3.5)

The option location=false can be given to indicate explicitly that only the infimum is wanted.

If there are multiple options for the keyword location then the last is used.

 > $\mathrm{minimize}\left(\mathrm{sin}\left(x\right),x=0..4,'\mathrm{location}','\mathrm{location}=\mathrm{false}'\right)$
 ${\mathrm{sin}}{}\left({4}\right)$ (3.6)
 > $\mathrm{minimize}\left(\mathrm{sin}\left(x\right),x=0..4,'\mathrm{location}=\mathrm{false}','\mathrm{location}'\right)$
 ${\mathrm{sin}}{}\left({4}\right){,}\left\{\left[\left\{{x}{=}{4}\right\}{,}{\mathrm{sin}}{}\left({4}\right)\right]\right\}$ (3.7) The location Data Structure

A location data structure (see previous section) can be used to quickly find the value of the function or the point(s) where the infimum is achieved (assuming the function is continuous and being minimized over a closed interval.)

 > $\mathrm{minima},\mathrm{points}:=\mathrm{minimize}\left(3-{x}^{2}-4{y}^{2},x=-4..4,y=-2..2,'\mathrm{location}'\right)$
 ${\mathrm{minima}}{,}{\mathrm{points}}{≔}{-29}{,}\left\{\left[\left\{{x}{=}{-4}{,}{y}{=}{-2}\right\}{,}{-29}\right]{,}\left[\left\{{x}{=}{-4}{,}{y}{=}{2}\right\}{,}{-29}\right]{,}\left[\left\{{x}{=}{4}{,}{y}{=}{-2}\right\}{,}{-29}\right]{,}\left[\left\{{x}{=}{4}{,}{y}{=}{2}\right\}{,}{-29}\right]\right\}$ (4.1)
 >
 $\left[{x}{,}{y}\right]{=}\left[{-4}{,}{-2}\right]$
 $\left[{x}{,}{y}\right]{=}\left[{-4}{,}{2}\right]$
 $\left[{x}{,}{y}\right]{=}\left[{4}{,}{-2}\right]$
 $\left[{x}{,}{y}\right]{=}\left[{4}{,}{2}\right]$ (4.2) Relation of the Location of the Minimum and the Infimum

If the infimum is finite then any location returned when option location is given indicates that that the infimum is either achieved at that point or approached arbitrarily closely in any open neighborhood around the point.  The location may not even be in the original interval being minimized over, but rather one of the endpoints of the interval.  If the infimum is $-\infty$ then the function is not bounded below on any open neighborhood of the point.

 > $\mathrm{minimize}\left(\mathrm{piecewise}\left(x=0,1,\left|x\right|\right),'\mathrm{location}'\right)$
 ${0}{,}\left\{\left[\left\{{x}{=}{0}\right\}{,}{0}\right]\right\}$ (5.1)
 > $\mathrm{minimize}\left(\mathrm{piecewise}\left(x=0,-1,\left|x\right|\right),'\mathrm{location}'\right)$
 ${-}{1}{,}\left\{\left[\left\{{x}{=}{0}\right\}{,}{-}{1}\right]\right\}$ (5.2)
 >
 ${1}{,}\left\{\left[\left\{{x}{=}{0}\right\}{,}{1}\right]\right\}$ (5.3)
 >
 ${-}{\mathrm{∞}}{,}\left\{\left[\left\{{x}{=}{0}\right\}{,}{-}{\mathrm{∞}}\right]\right\}$ (5.4)
 >