Skip to content

FunctionConvexity ​

1 if f is convex over its whole domain, -1 if concave, 0 if affine, Indeterminate otherwise.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageFunctionConvexity!
FunctionConvexity(f, x)the convexity of f in the real variable x over the whole real line, from the sign of its second derivative.
Typed signatures
TypePackageApplies
(expression, symbol) -> expressionanalyticalways

Domain: Elementary functions

Details
  • Same domain-first convention as FunctionMonotonicity -- a domain that isn't all of R\mathbb R answers Indeterminate (confirmed against wolframscript), it isn't a decline.
  • For a polynomial, reads the sign of the second derivative in closed form; Exp of an affine argument is always convex (a2eax+b>0a^2 e^{ax+b}>0).
  • Declines only where the classifier itself declines, or where a polynomial's second derivative is a genuine multi-term polynomial of degree > 2.

Examples

Basic #

A parabola is convex everywhere

live ↗
InFunctionConvexity(x2,x)\mathrm{FunctionConvexity}(x^2, x)Out11

Known value · Wolfram 15.0.0, hand cross-checked

A cubic's second derivative changes sign at the inflection point

live ↗
InFunctionConvexity(x3,x)\mathrm{FunctionConvexity}(x^3, x)OutFunctionConvexity(x3,x)\mathrm{FunctionConvexity}(x^3, x)

Known value · Wolfram 15.0.0, hand cross-checked

Exp is always convex

live ↗
InFunctionConvexity(ex,x)\mathrm{FunctionConvexity}(e^{x}, x)Out11

Known value · Wolfram 15.0.0, hand cross-checked

Scope #
live ↗
InMap(_1⁡↦FunctionConvexity(_1⁡,[x,y]),[x2,x2+y2])\mathrm{Map}(\operatorname{\_1}↦\mathrm{FunctionConvexity}(\operatorname{\_1}, \bigl\lbrack x, y\bigr\rbrack), \bigl\lbrack x^2, x^2+y^2\bigr\rbrack)Out[FunctionConvexity(x2,[x,y]),FunctionConvexity(x2+y2,[x,y])]\bigl\lbrack\mathrm{FunctionConvexity}(x^2, \bigl\lbrack x, y\bigr\rbrack), \mathrm{FunctionConvexity}(x^2+y^2, \bigl\lbrack x, y\bigr\rbrack)\bigr\rbrack
Applications #

The parabola opens upward, so it is convex (1)

live ↗
InFunctionConvexity(x2−1,x)\mathrm{FunctionConvexity}(x^2-1, x)Out11
Properties #

1/x's domain isn't all of R, so we decline rather than guess about its (genuinely mixed) shape

live ↗
InFunctionConvexity(1x,x)\mathrm{FunctionConvexity}(\frac{1}{x}, x)OutFunctionConvexity(1x,x)\mathrm{FunctionConvexity}(\frac{1}{x}, x)
About
Examples6
Checked againstWolfram Language 3 agree3 differ
CrosswalkWolfram Language