maximize - Maple Help

minimize

compute the minimum symbolically

maximize

compute the maximum symbolically

 Calling Sequence minimize(expr, opt1, opt2, ..., optn) maximize(expr, opt1, opt2, ..., optn)

Parameters

 expr - algebraic expression opt1, opt2, ..., optn - options -- see below

Description

 • The minimize(expr, opt1, opt2, ..., optn) function returns the infimum of expr if possible.  If minimize cannot find the infimum, it returns an unevaluated function call.
 • If the option location or location = true is given then the output is an expression sequence with the first argument being the minimum and the second a set of lists, where the first argument of each list is a set of substitutions that describe a point at or in a neighborhood of where the infimum is either achieved or approached.  If minimize returns unevaluated, the second argument is the empty set {} and the location flag is removed.
 • If an option is a name equated to a range then minimize finds the infimum of that function over the given range.  If the range is the entire real line -infinity..infinity then range can be omitted.
 • The variables over which the expression are to be minimized can be given implicitly as options or explicitly as a list containing all such variable ranges.  This second format is necessary if one is minimizing with respect to a variable that appears as an option to minimize.
 • If no names over which to minimize are given then minimize finds the infimum over all indeterminates of type name.
 • The function maximize is defined to compute the negative of the result of minimize applied to the negated expr.
 • The solvers in the Optimization package can also be used for minimization and maximization of expressions.  These solvers allow constraints to be specified and are generally more efficient than the minimize and maximize commands.  However, they perform all computation using floating-point values and return only local solutions to non-convex optimization problems.

Examples

 > $\mathrm{minimize}\left(\mathrm{cos}\left(x\right),x=1..3\right)$
 ${\mathrm{cos}}{}\left({3}\right)$ (1)
 > $\mathrm{maximize}\left(\mathrm{cos}\left(x\right),x=1..3\right)$
 ${\mathrm{cos}}{}\left({1}\right)$ (2)
 > $\mathrm{minimize}\left({ⅇ}^{\mathrm{tan}\left(x\right)},x=0..10\right)$
 ${0}$ (3)
 > $\mathrm{minimize}\left({x}^{2}-3x+{y}^{2}+3y+3\right)$
 ${-}\frac{{3}}{{2}}$ (4)
 > $\mathrm{minimize}\left({x}^{2}-3x+{y}^{2}+3y+3,\mathrm{location}\right)$
 ${-}\frac{{3}}{{2}}{,}\left\{\left[\left\{{x}{=}\frac{{3}}{{2}}{,}{y}{=}{-}\frac{{3}}{{2}}\right\}{,}{-}\frac{{3}}{{2}}\right]\right\}$ (5)
 > $\mathrm{minimize}\left({x}^{2}-3x+{y}^{2}+3y+3,x=2..4,y=-4..-2,\mathrm{location}\right)$
 ${-1}{,}\left\{\left[\left\{{x}{=}{2}{,}{y}{=}{-2}\right\}{,}{-1}\right]\right\}$ (6)
 > $\mathrm{maximize}\left({x}^{2}-3x+{y}^{2}+3y+3,x=2..4,y=-4..-2,\mathrm{location}\right)$
 ${11}{,}\left\{\left[\left\{{x}{=}{4}{,}{y}{=}{-4}\right\}{,}{11}\right]\right\}$ (7)
 > $\mathrm{minimize}\left(\left|{ⅇ}^{-{x}^{2}}-\frac{1}{2}\right|,x=-4..4,\mathrm{location}\right)$
 ${0}{,}\left\{\left[\left\{{x}{=}\sqrt{{\mathrm{ln}}{}\left({2}\right)}\right\}{,}{0}\right]{,}\left[\left\{{x}{=}{-}\sqrt{{\mathrm{ln}}{}\left({2}\right)}\right\}{,}{0}\right]\right\}$ (8)
 > $\mathrm{maximize}\left(\left|{ⅇ}^{-{x}^{2}}-\frac{1}{2}\right|,x=-4..4\right)$
 $\frac{{1}}{{2}}$ (9)
 > $\mathrm{minimize}\left({x}^{4}-{x}^{2},x=-3..3,\mathrm{location}=\mathrm{true}\right)$
 ${-}\frac{{1}}{{4}}{,}\left\{\left[\left\{{x}{=}{-}\frac{\sqrt{{2}}}{{2}}\right\}{,}{-}\frac{{1}}{{4}}\right]{,}\left[\left\{{x}{=}\frac{\sqrt{{2}}}{{2}}\right\}{,}{-}\frac{{1}}{{4}}\right]\right\}$ (10)
 > $\mathrm{minimize}\left({x}^{2}+\mathrm{cos}\left(x\right),\left[x=0..3\right]\right)$
 ${1}$ (11)

'location' is an option and therefore all variables to be minimized over must be placed in a list

 > $\mathrm{minimize}\left(\mathrm{sin}\left(\mathrm{location}y\right),\left[\mathrm{location}=1..1,y=-1..1\right],\mathrm{location}\right)$
 ${-}{\mathrm{sin}}{}\left({1}\right){,}\left\{\left[\left\{{y}{=}{-1}\right\}{,}{-}{\mathrm{sin}}{}\left({1}\right)\right]\right\}$ (12)

Changing the setting for Normalizer environment variable can in some cases simplify the solution.

 > $f≔{\left({x}^{2}+{y}^{2}\right)}^{2}+\frac{1}{{x}^{2}+{y}^{2}}+{\left({x}^{2}-2x+1+{y}^{2}\right)}^{2}+\frac{1}{{x}^{2}-2x+1+{y}^{2}}:$
 > $\mathrm{alias}\left(r=\mathrm{RootOf}\left(2{\mathrm{_Z}}^{2}-2\mathrm{RootOf}\left(2{\mathrm{_Z}}^{3}-1,\mathrm{index}=1\right)-2\mathrm{_Z}+1,1.237360513\right)\right)$
 ${r}$ (13)
 > $\mathrm{minimize}\left(f\right)$
 $\frac{{8}{}{{r}}^{{6}}{-}{24}{}{{r}}^{{5}}{+}{36}{}{{r}}^{{4}}{-}{32}{}{{r}}^{{3}}{+}{18}{}{{r}}^{{2}}{-}{6}{}{r}{+}{9}}{{2}{}\left({2}{}{{r}}^{{2}}{-}{2}{}{r}{+}{1}\right)}$ (14)
 > $\mathrm{Normalizer}≔\mathrm{simplify}:$
 > $\mathrm{minimize}\left(f\right)$
 ${3}{}{{2}}^{{1}}{{3}}}$ (15)

Note that assumptions may be placed on the location of the minima, especially if the function is periodic and contains equally valued minima at multiple locations.

 > $\mathrm{minimize}\left(\mathrm{sin}\left(x\right)+\mathrm{cos}\left(x\right),x=0..20,\mathrm{location}\right)$
 ${-}\sqrt{{2}}{,}\left\{\left[\left\{{x}{=}\left(\frac{{5}}{{4}}{+}{2}{}{\mathrm{_Z16}}\right){}{\mathrm{\pi }}\right\}{,}{-}\sqrt{{2}}\right]\right\}$ (16)
 > $\mathrm{about}\left(\mathrm{indets}\left({2}_{},'\mathrm{suffixed}'\left(\left\{'\mathrm{_Z}'\right\},'\mathrm{integer}'\right)\right)\right)$
 {_Z16}:   is used in the following assumed objects   [_Z16] assumed AndProp(integer,RealRange(0,2))

The solutions can be made explicit by setting _EnvExplicit to true.

 > $\mathrm{_EnvExplicit}≔\mathrm{true}:$
 > $\mathrm{minimize}\left(\mathrm{sin}\left(x\right)+\mathrm{cos}\left(x\right),x=0..20,\mathrm{location}\right)$
 ${-}\sqrt{{2}}{,}\left\{\left[\left\{{x}{=}\frac{{5}{}{\mathrm{\pi }}}{{4}}\right\}{,}{-}\sqrt{{2}}\right]{,}\left[\left\{{x}{=}\frac{{13}{}{\mathrm{\pi }}}{{4}}\right\}{,}{-}\sqrt{{2}}\right]{,}\left[\left\{{x}{=}\frac{{21}{}{\mathrm{\pi }}}{{4}}\right\}{,}{-}\sqrt{{2}}\right]\right\}$ (17)