Function Repository Resource:

# LocalExtrema

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

Contributed by: Wolfram|Alpha Math Team
 ResourceFunction["LocalExtrema"][expr,x] computes the local maxima and minima of expr with respect to x. ResourceFunction["LocalExtrema"][expr,{x,y,…}] computes the local maxima and minima of expr with respect to multiple variables. ResourceFunction["LocalExtrema"][{expr,const},{x,y,…}] computes the local maxima and minima of expr subject to the constraint const.

## Details and Options

ResourceFunction["LocalExtrema"] returns an association of the form <|"Maxima"{fmax,{xxmax,yymax,}},"Minima"{fmin,{xxmin,yymin,}}|>.
The const can contain equations, inequalities or logical combinations of these.
ResourceFunction["LocalExtrema"] only returns results when there is a bounded extremum.

## Examples

### Basic Examples (2)

Compute the local extrema of a curve:

 In[1]:=
 Out[1]=

Plot them:

 In[2]:=
 Out[2]=

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

 In[3]:=
 Out[3]=

### Scope (2)

Compute the extrema of a function of two variables:

 In[4]:=
 Out[4]=

Compute the extrema of a piecewise function:

 In[5]:=
 Out[5]=

Plot the result:

 In[6]:=
 Out[6]=

### Possible Issues (1)

LocalExtrema may return duplicate results for periodic functions:

 In[7]:=
 Out[7]=

## Publisher

Wolfram|Alpha Math Team

## Version History

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

## Author Notes

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

 In[1]:=