Function Repository Resource:

LocalMinima

Source Notebook

Compute the local minima of an expression with respect to the given variables

Contributed by: Wolfram|Alpha Math Team

ResourceFunction["LocalMinima"][expr,x]

computes the local minima of expr with respect to x.

ResourceFunction["LocalMinima"][expr,{x,y,}]

computes the local minima of expr with respect to multiple variables.

ResourceFunction["LocalMinima"][{expr,const},{x,y,}]

computes the local minima of expr subject to the constraint const.

Details and Options

ResourceFunction["LocalMinima"] returns a list with each minimum in the form {fmin,{xxmin,yymin,}}.
The const can contain equations, inequalities or logical combinations of these.
ResourceFunction["LocalMinima"] only returns results when there is a bounded minimum.

Examples

Basic Examples (2) 

Compute the local minima of a polynomial:

In[1]:=
ResourceFunction["LocalMinima"][x (x - 1) (x + 1), x]
Out[1]=

Plot them:

In[2]:=
Plot[x (x - 1) (x + 1), {x, -2, 2}, Epilog -> {
Directive[Red, 
PointSize[Large]], 
Point[{1/Sqrt[3], -(2/(3 Sqrt[3]))}]}]
Out[2]=

Scope (2) 

Use a constraint in order to reduce the domain upon which minima can be found:

In[3]:=
ResourceFunction["LocalMinima"][{Sin[x], 0 < x < 4 Pi}, x]
Out[3]=

Compute the minima of a function of two variables:

In[4]:=
ResourceFunction["LocalMinima"][( x^2 + y^2 - 4)^2, {x, y}]
Out[4]=

Possible Issues (1) 

LocalMinima may return duplicate results for periodic functions:

In[5]:=
ResourceFunction["LocalMinima"][Sin[x], x]
Out[5]=

Publisher

Wolfram|Alpha Math Team

Version History

  • 2.0.0 – 23 March 2023
  • 1.0.0 – 18 September 2020

Related Resources

Author Notes

To view the full source code for LocalMinima, run the following code:

In[1]:=
FileNameJoin[
  ReplacePart[
   FileNameSplit[FindFile["ResourceFunctionHelpers`"]], -1 -> "FindExtrema.wl"]] // SystemOpen

License Information