Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Compute the regions on which an expression is concave up or down
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. |
Compute the regions on which a curve is concave up or down:
| In[1]:= |
| Out[1]= |
Return plots as well as the regions:
| In[2]:= |
| Out[2]= | ![]() |
Use the "NumberLine" property to visualize the regions directly:
| In[3]:= |
| Out[3]= | ![]() |
Use the "Plot" property to visualize the regions on the plot of the curve:
| In[4]:= |
| 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]:= |
| Out[5]= |
To test that 0 is the only point where the second derivative is 0, use Resolve:
| In[6]:= |
| Out[6]= |
FunctionConcavity returns strict regions of the second derivative being non-zero as can be seen in this Piecewise expression:
| In[7]:= |
| In[8]:= |
| Out[8]= | ![]() |
| In[9]:= |
| Out[9]= | ![]() |
Working with the absolute value function Abs may return unexpected results:
| In[10]:= |
| Out[10]= |
This is due to the assumption of Complex inputs to Abs in comparison to RealAbs:
| In[11]:= |
| Out[11]= |
Using RealAbs returns the expected results:
| In[12]:= |
| Out[12]= |
Compute the concavity of a periodic function and visualize it:
| In[13]:= |
| Out[13]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License