
%Declare variables
sdpvar x y

%Define polynomial
p=1+x^2-x*y^2+y^4;

%Declare sum of squares condition
F=sos(p);

%Semidefinite programming step (solve the sos problem)
solvesos(F);

%Display the factors of the sum of squares
h=sosd(F);
sdisplay(h)

%Check the (numerical) answer
sdisplay(h'*h)