# The solutions of cvx and quadprog are different

Hello everyone,
I’ve been trying to resolve a quadratic programming problem by cvx (using Mosek sovler) and the function of matlab quadprog respectively. However, the solutions of the two softwares are so different. How does it happen? Thanks.

``````p1 = quadprog(A/2,b',e',2,[],[],0.1*e,e);

cvx_begin quiet
variable p2(10,1)
minimize quad_form( p2, A ) + b*p2
subject to
0.1<= p2(:) <= 1;
sum(p2) <= 2;
cvx_end
stem(p1),hold on
stem(p)
``````

where

``````A = [3.32629019178030,0,0,0,0,0,0,0,0,0;0,2.10581206558217,0,0,0,0,0,0,0,0;0,0,3.64741895165455,0,0,0,0,0,0,0;0,0,0,23.1206992064773,0,0,0,0,0,0;0,0,0,0,1.75894526073874,0,0,0,0,0;0,0,0,0,0,1.86317807105937,0,0,0,0;0,0,0,0,0,0,1.49887873238688,0,0,0;0,0,0,0,0,0,0,2.79583082768369,0,0;0,0,0,0,0,0,0,0,1.91424455866617,0;0,0,0,0,0,0,0,0,0,1.94317803591562];
b = [-5.11759625540976,-5.10360693965440,-4.84515685603946,-10.4642464145880,-4.40249742725508,-4.76098097312293,-3.92338335654864,-5.21858206082626,-4.79164073570925,-5.03263659777103];
e = ones(10,1);``````

You should have 2*A instead of A/2 in the call to quadprog to make the problems equivalent.

OMG…thank you:joy: