Maximizing polynomial

Hi, I want to maximize a simple function:

V=(140*h - 48*h*h + 4*h*h*h)
with h being 
h>=0
h<=5

But MATLAB is throwing following error:
Illegal operation: {log-affine} - {log-affine}

Here is a plot
http://www.wolframalpha.com/input/?i=(140h±+48hh+%2B+4hhh),+for+h%3E0,+h%3C5

Is there a way to solve it with CVX?

cvx_begin gp
    variables h
    maximize (140*h - 48*h*h + 4*h*h*h)
    subject to
     h>=0
     h<=5
cvx_end

This is non-convex. Why isn't CVX accepting my model? READ THIS FIRST!

can anyone help me to find maximum of this function using cvx. ( (1+(2-x).^2)/(1 + x.^2) )

used this code but had some errors because this function has convex and concave part.

cvx_begin
variable x
maximize ( (1+(2-x).^2)/(1 + x.^2) )
subject to
x < 0
cvx_end

You’re correct. That function is convex and concave in varying portions of your constrained region x < 0. Hence CVX is not applicable. Why isn’t CVX accepting my model? READ THIS FIRST!

1 Like