>

$\mathrm{with}\left(\mathrm{Optimization}\right)\:$

Solve a linear programming problem specified using algebraic form. The objective function and the constraints are expressions in x and y.
>

$\mathrm{LPSolve}\left(4x5y\,\left\{x\+2y\le 6\,5x\+4y\le 20\,0\le x\,0\le y\right\}\right)$

$\left[{\mathrm{19.}}{\,}\left[{x}{=}{2.66666666666667}{\,}{y}{=}{1.66666666666667}\right]\right]$
 (1) 
Solve a linear programming problem specified using Matrix form.
>

$\mathrm{LPSolve}\left(\u27e84\,5\u27e9\,\left[\u27e8\u27e83\1\u27e9\,\u27e85\1\u27e9\u27e9\,\u27e8\frac{1}{2}\,2\u27e9\right]\,\left[0\,\mathrm{\∞}\right]\,\mathrm{maximize}\right)$

$\left[{6.06250000000000}{\,}\left[\begin{array}{c}{0.187500000000000}\\ {1.06250000000000}\end{array}\right]\right]$
 (2) 
Quadratic programming problems can be specified in algebraic form or in Matrix form.
>

$\mathrm{QPSolve}\left(2x\+5y\+3{x}^{2}\+3xy\+2{y}^{2}\,\left\{2\le xy\right\}\right)$

$\left[{\mathrm{3.53333333333333}}{\,}\left[{x}{=}{0.466666666666667}{\,}{y}{=}{\mathrm{1.60000000000000}}\right]\right]$
 (3) 
>

$\mathrm{QPSolve}\left(\left[\u27e82\,5\u27e9\,\u27e8\u27e86\3\u27e9\,\u27e83\4\u27e9\u27e9\right]\,\left[\u27e8\u27e81\1\u27e9\u27e9\,\u27e82\u27e9\right]\,\mathrm{assume}\=\mathrm{nonnegative}\right)$

$\left[{16.}{\,}\left[\begin{array}{c}{2.}\\ {0.}\end{array}\right]\right]$
 (4) 
Nonlinear programs can be specified in algebraic form or in Matrix form.
>

$\mathrm{NLPSolve}\left({\mathrm{sin}\left(x\right)}^{3}\frac{1}{1\+{x}^{4}}\,\mathrm{initialpoint}\=\left\{x\=2\right\}\right)$

$\left[{\mathrm{0.0107674612530566632}}{\,}\left[{x}{=}{3.07244485023085}\right]\right]$
 (5) 
You should provide the gradient of the objective function if you want to use NLPSolve in Matrix form.
>

obj := proc(v)
10*v[1]^2  2*v[1]*v[2]^2 + v[2]^4 + 1  2*v[2] + v[2]^2
end proc:

>

objgrad := proc(v, w)
w[1] := 20*v[1]  2*v[2]^2:
w[2] := 4*v[1]*v[2] + 4*v[2]^3  2 + 2*v[2]
end proc:

>

$\mathrm{NLPSolve}\left(2\,\mathrm{obj}\,\mathrm{objectivegradient}\=\mathrm{objgrad}\right)$

$\left[{0.276597509679878506}{\,}\left[\begin{array}{c}{0.0364560120817733}\\ {0.603788442821000}\end{array}\right]\right]$
 (6) 