Function Repository Resource:

FunctionConcavity

Source Notebook

Compute the regions on which an expression is concave up or down

Contributed by: Wolfram|Alpha Math Team

ResourceFunction["FunctionConcavity"][f,x]

returns an association of information about whether f is concave up or concave down with respect to x.

ResourceFunction["FunctionConcavity"][f,x,property]

returns a specific property related to whether f is concave up or concave down with respect to x.

Details and Options

ResourceFunction["FunctionConcavity"] expects f to be a univariate expression in terms of x, similar to what might be entered into Plot.
ResourceFunction["FunctionConcavity"] returns regions on which the second derivative of expr with respect to x is greater than 0 (concave up) or less than 0 (concave down).
The input property can be any of All, "ConcaveUp", "ConcaveDown", "Regions", "Plot" or "NumberLine", and defaults to "Regions".

Examples

Basic Examples (2) 

Compute the regions on which a curve is concave up or down:

In[1]:=
ResourceFunction["FunctionConcavity"][(x + 2)^2 (x - 2)^2, x]
Out[1]=

Return plots as well as the regions:

In[2]:=
ResourceFunction["FunctionConcavity"][(x + 2)^2 (x - 2)^2, x, All]
Out[2]=

Scope (4) 

Use the "NumberLine" property to visualize the regions directly:

In[3]:=
ResourceFunction["FunctionConcavity"][
 x^5 - 10 x^4 + 10 x^3 - x^2 - x, x, "NumberLine"]
Out[3]=

Use the "Plot" property to visualize the regions on the plot of the curve:

In[4]:=
ResourceFunction["FunctionConcavity"][
 x^5 - 10 x^4 + 10 x^3 - x^2 - x, x, "Plot"]
Out[4]=

Note that at stationary points of the expression, the curve is neither concave up nor concave down. In this case, 0 is a member of neither of the regions:

In[5]:=
ResourceFunction["FunctionConcavity"][x^3, x]
Out[5]=

To test that 0 is the only point where the second derivative is 0, use Resolve:

In[6]:=
Resolve[ForAll[{x}, x \[Element] Reals && x != 0, D[x^3, x] != 0]]
Out[6]=

FunctionConcavity returns strict regions of the second derivative being non-zero as can be seen in this Piecewise expression:

In[7]:=
f = Piecewise[{{x^3, x < 0}, {0, 0 <= x <= 2}, {(x - 2)^3, x > 2}}];
In[8]:=
ResourceFunction["FunctionConcavity"][f, x, "NumberLine"]
Out[8]=
In[9]:=
ResourceFunction["FunctionConcavity"][f, x, "Plot"]
Out[9]=

Possible Issues (3) 

Working with the absolute value function Abs may return unexpected results:

In[10]:=
ResourceFunction["FunctionConcavity"][Abs[x^3], x]
Out[10]=

This is due to the assumption of Complex inputs to Abs in comparison to RealAbs:

In[11]:=
{D[Abs[x^3], {x, 2}], D[RealAbs[x^3], {x, 2}]}
Out[11]=

Using RealAbs returns the expected results:

In[12]:=
ResourceFunction["FunctionConcavity"][RealAbs[x^3], x]
Out[12]=

Neat Examples (1) 

Compute the concavity of a periodic function and visualize it:

In[13]:=
ResourceFunction["FunctionConcavity"][Sin[x], x, All]
Out[13]=

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 FunctionConcavity, run the following code:

License Information