// min S(x) = 4 * x1^2 + 5 * x2^2
//  s.a. h(x) = 2 * x1 + 3 * x2 - 6 = 0
//
//  x' = [1.071  1.286]

Q=[4 0;0 5]*2
c=[0; 0]
A=[]
b=[]
Aeq=[2 3]
beq=6
lb=[-Inf;-Inf]
ub=[Inf;Inf]

op=optimset('LargeScale','off');
[x,s,ex,out,lambda]=quadprog(Q,c,A,b,Aeq,beq,lb,ub,[],op)

Al=[Aeq 0 0 0;Q Aeq' -eye(2)]
bl=[beq;0;0]
cl=0.5*[0;0;-beq;0;0]
LB=[0;0;-Inf;-Inf;-Inf];
UB=[Inf;Inf;0;0;0];
//[X,FVAL,EXITFLAG,OUTPUT,LAMBDA]=linprog(cl,[],[],Al,bl,LB,UB,[],op)
[X,FVAL]=linprog(cl,[],[],Al,bl,LB,UB)

A2=[Aeq 0 0 0;Q -Aeq' eye(2)]
b2=[beq;0;0]
c2=0.5*[0;0;beq;0;0]
LB2=[0;0;0;0;0];
UB2=[Inf;Inf;Inf;Inf;Inf];
//[X2,FVAL2,EXITFLAG2,OUTPUT2,LAMBDA2]=linprog(c2,[],[],A2,b2,LB2,UB2,[],op)
[X2,FVAL2]=linprog(c2,[],[],A2,b2,LB2,UB2)
