Previous Up Next

13.7.8  Determining where a function is convex

The convex command determines where a function is convex.

Examples

Verify that f(x)=3 ex+5x4−ln(x) is convex on ℝ:

convex(3*exp(x)+5x^4-ln(x),x)
     
true           

Verify that f(x,y,z)=x2+y2+3z2x y+2x z +y z is convex on ℝ3:

convex(x^2+y^2+3z^2-x*y+2x*z+y*z,[x,y,z])
     
true           

The function f(x1,x2)=x13+2x12+2x1 x2+x22/2−8x1−2x2−8 is convex on [0,+∞⟩×ℝ:

convex(x1^3+2x1^2+2*x1*x2+x2^2/2-8x1-2x2-8,[x1,x2],simplify)
     

x1≥ 0
          

Find the values of a∈ℝ for which the function f(x,y,z)=x2+x z+a y z+z2 is convex:

convex(x^2+x*z+a*y*z+z^2,[x,y,z])
     
false           

Note that the function is convex for a=0. However, the convex command does not support equalities as convexity constraints.

Find all values a∈ℝ for which the function f(x,y,z)=x2+2 y2+a z2−2 x y+2 x z−6 y z is convex on ℝ3:

convex(x^2+2y^2+a*z^2-2x*y+2x*z-6y*z,[x,y,z],simplify)
     

a≥ 5
          

Find the set S⊂ℝ2 on which the function f:ℝ2→ℝ defined by f(x1,x2)=ex1+ ex2+x1 x2 is convex:

condition:=convex(exp(x1)+exp(x2)+x1*x2,[x1,x2],simplify)
     

ex1 ex2−1≥ 0
          
lin(condition)
     

ex1+x2−1≥ 0
          

(See Section 10.3.4.) From here you conclude that f is convex when x1+x2≥ 0. The set S is therefore the half-space defined by this inequality.

The domain of the input function can be restricted by setting assumptions on variables:

assume(x1>0),assume(x2>0):; convex(exp(x1)+exp(x2)+x1*x2,[x1,x2])
     
true           

which was already verified in the previous example.


Previous Up Next