Created
May 23, 2023 08:08
-
-
Save johanlofberg/19136ec5dc44ced6a5ef1ee05cb27acb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Naive sos model | |
x = sdpvar(1,1); | |
y = sdpvar(1,1); | |
z = sdpvar(1,1); | |
p = 12+y^2-2*x^3*y+2*y*z^2+x^6-2*x^3*z^2+z^4+x^2*y^2; | |
options = sdpsettings('sos.newton',0,'sos.congruence',0); | |
[sol,v,Q] = solvesos(sos(p),[],options); | |
%% Newton polytope | |
options = sdpsettings('sos.newton',1,'sos.congruence',0); | |
[sol,v,Q] = solvesos(sos(p),[],options); | |
%% Visualize Newton polytope | |
clf | |
N = getexponentbase(newtonmonoms(p),[x y z]); | |
s = sdpvar(length(N),1);q = sdpvar(3,1); | |
plot([q == N'*s, sum(s)==1,s>=0],q,'b',[],sdpsettings('plot.shade',0.2)) | |
hold on | |
m = plot3(N(:,1),N(:,2),N(:,3),'yo'); | |
set(m,'Markersize',10); | |
set(m,'Markerface','yellow'); | |
%% Symmetry reduction | |
options = sdpsettings('sos.newton',1,'sos.congruence',1); | |
[sol,v,Q] = solvesos(sos(p),[],options); | |
%% Post-processing | |
options = sdpsettings('sos.numblkdg',1e-4); | |
[sol,v,Q] = solvesos(sos(p),[],options); | |
Q{1} | |
x = sdpvar(1,1); | |
y = sdpvar(1,1); | |
z = sdpvar(1,1); | |
w = sdpvar(1,1); | |
p = 8*x^6*w^6*y^2+4*z^4*y^8*x^2+4*z^4*y^4*x^4+8*z^4*y^6*x^2+... | |
4*x^8*w^6*y^2+4*z^4*y^4*x^2+4*z^6*y^8*x^2+8*y^2*x^6*w^4+... | |
4*x^4*y^4*w^4-2*x^6*y^6-16*z^4*y^4*x^4*w^2-16*z^4*y^4*x^2*w^4-... | |
20*z^4*y^4*x^6*w^2-24*z^4*y^4*x^6*w^4+12*z^4*y^6*x^2*w^2-... | |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*x^4+6*z^2*w^4*x^6+3*z^2*w^4*x^8+2*z^4*w^4*x^4+... | |
4*z^4*w^4*x^6+2*z^4*w^4*x^8-16*z^2*w^4*x^6*y^6-4*z^2*w^4*x^2*y^8+... | |
12*z^2*w^4*x^8*y^4-4*x^2*w^4*y^2*z^2-2*x^2*y^2*z^2*w^2+... | |
8*x^8*y^4*z^2*w^6-4*x^6*w^4*y^6+6*x^8*w^4*y^4+2*x^4*w^4*y^8+... | |
2*x^4*z^2*w^6+2*y^4*z^6*w^2+y^4*z^6+x^4*w^6+2*y^6*z^6+4*x^4*y^8*z^6+... | |
4*x^8*y^4*w^6+4*x^2*y^4*z^6+8*x^2*y^6*z^6+4*x^4*y^4*z^6+... | |
2*y^8*z^6*w^2+8*x^6*w^6*y^4+4*x^4*w^6*y^2+4*x^4*w^6*y^4+... | |
2*x^8*w^6*z^2+8*x^4*y^8*z^6*w^2+8*x^2*y^4*z^6*w^2+16*x^2*y^6*z^6*w^2+... | |
8*x^4*y^4*z^6*w^2+16*x^6*w^6*y^4*z^2+8*x^8*w^6*y^2*z^2+... | |
8*x^4*w^6*y^4*z^2+8*x^4*w^6*y^2*z^2+16*x^6*w^6*y^2*z^2+... | |
y^8*z^6+2*x^6*w^6+x^8*w^6+4*x^6*w^6*z^2+16*x^4*y^6*z^6*w^2+... | |
8*z^6*y^6*x^4+4*z^6*y^6*w^2+8*x^2*y^8*z^6*w^2 | |
[sol,v,Q,res] = solvesos(sos(p)) | |
[sol,v,Q,res] = solvesos(sos(p),[],sdpsettings('sos.numblk',1e-6)) | |
spy(Q{1}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment