Can you explain this situation?

hello. i use CVX in the MATLAB.

i want to find the q, which minimize objective function.

But, CVX can not find the q what i want.

even the fminbnd, which is matlab function, can find the q.

is there any fault?

here is my MATLAB code.

clear all
clc;

a = abs(randn(1,1));
b = abs(randn(1,1));
c = abs(randn(1,1));
d = abs(randn(1,1));
e = abs(randn(1,1));


cvx_begin
    variable q
    minimize( a*pow_pos(q,4) + b*pow_pos(q,3) + c*square(q) + d*q + e )
cvx_end
CVX_Rq = q;
CVX_Out = cvx_optval;
Mvalue = 1e3;
f = @(x)a*(x^4) + b*(x^3) + c*(x^2) + d*x + e;
[MAT_Rq min_Value] = fminbnd(f, -Mvalue, Mvalue);

CVX_Out = a*(CVX_Rq^4) + b*(CVX_Rq^3) + c*(CVX_Rq^2) + d*CVX_Rq + e;
MAT_Out = a*(MAT_Rq^4) + b*(MAT_Rq^3) + c*(MAT_Rq^2) + d*MAT_Rq + e;

Result = [CVX_Rq MAT_Rq;
          CVX_Out MAT_Out]

T=linspace(-10,10,1000);
Y = a*(T.^4) + b*(T.^3) + c*(T.^2) + d*T + e;
min(Y)
figure(1)
plot(T,Y)

You are solving DIFFERENT problems in CVX and fminbnd .I wasn’t complete enough in my answer to your previous question (help) Disciplined convex programming error: Invalid quadratic form(s): not a square , which served as the basis for your CVX code in this current topic.

pow_pos(q,3) is not the same as q^3. they are the same when q >= 0. However, when q < 0, the former is 0, whereas the latter is the negative number, q^3.

As I wrote in your earlier question, your original problem as written was non-convex. However, if a, b, c are all nonnegative, and q is constrained to be nonnegative, then the program can be rewritten using pow_pos. However, I should have specified that either an explicit nonegativity constraint needed to be specified for q, or d*q should have been replaced by d*pos(q). Otherwise, CVX could make q negative to the improper benefit of its objective function through the d*q term… If you do that, and make 0 the lower bound for fminbnd, then you should get agreement (presuming the upper bound for fminbnd is high enough).