NCSOStoolsdemo - Extracting minimizers or trace minimizers

%**************************************************************************

% Extracting minimizers or trace minimizers                               *

%**************************************************************************

% -------------------------------------------------------------------------

% First we construct some symbolic noncommuting variables

% -------------------------------------------------------------------------

>> NCvars x y

% -------------------------------------------------------------------------

% We can compute minimizers and the minimum of the polynomial.

% -------------------------------------------------------------------------

>> f = (1 - y + x*y + y*x)'*(1 - y + x*y + y*x) + (-2 + y^2)^2 + (-x + x^2)^2;

>> [X,fX,eig_val,eig_vec] = NCopt(f)

***** NCSOStools: module NCopt started *****

Number of linear constraints: 43.

Starting SDP solver ...

***** Warning: Some numerical problems occur. *****

***** Starting advanced testing ... preparing for SDP solver ... *****

***** Presumably everything is OK.  *****

***** Continue ...                  *****

***** NCSOStools: module GNS started *****

found 4 linearly independent vectors ...

using corresponding columns of a matrix ...

using corresponding words in a cell of monomials ...

constructing final matrices ... done.

***** NCSOStools: module GNS completed *****

Evaluating X ..... completed.

*** Minimum eigenvalue for f is 0.000000. ***

***** NCSOStools: module NCopt completed *****

X = Columns 1 through 8

     0.1491    0.1174    0.3288    0.0608    0.1174    0.9385   -0.0008   -0.2511

     1.4113   -0.0872    0.0196   -0.0089   -0.0872   -1.3222    0.0903   -0.4389

    Columns 9 through 16

     0.3288   -0.0008    0.7768    0.0734    0.0608   -0.2511    0.0734   -0.6953

     0.0196    0.0903   -1.3207   -0.4341   -0.0089   -0.4389   -0.4341    0.9758

fX =  0.0107   -0.0222    0.0063   -0.1085

     -0.0222    0.2485    0.1845   -0.2726

      0.0063    0.1845    0.2080   -0.4218

     -0.1085   -0.2726   -0.4218    3.7686

eig_val = 0.0000         0         0         0

               0    0.0424         0         0

               0         0    0.3488         0

               0         0         0    3.8447

eig_vec = 0.9304    0.3561   -0.0828    0.0277

          0.2806   -0.5590    0.7760    0.0809

         -0.2351    0.7469    0.6106    0.1189

          0.0208    0.0540    0.1345   -0.9892

% It means that with A=reshape(X(1,:),4,4) and B=reshape(X(2,:),4,4) we get

% f(A,B) as fX with minimal eigenvalue eig_val(1,1) (which is also a

% minimum) and corresponding eigenvector eig_vec(:,1).

% -------------------------------------------------------------------------

% Whenever the tracial moment matrix corresponding to the polynomial is

% flat we can also compute trace minimizers and the trace minimum of that

% polynomial

% -------------------------------------------------------------------------

>> f1 = 3 + x^2 + 2*x^3 + 2*x^4 + x^6 - 4*x^4*y + x^4*y^2 + 4*x^3*y;

>> f2 = 2*x^3*y^2 - 2*x^3*y^3 + 2*x^2*y - x^2*y^2 + 2*x^2*y^3 - 4*x*y;

>> f3 = 8*x*y*x*y + 4*x*y^2 + 6*x*y^4 - 2*y + y^2 - 4*y^3 +  2*y^4 + 2*y^6;

>> f = f1 + f2 + f3;

>> [X,f_min] = NCcycOpt(f)

***** NCSOStools: module NCcycOpt started *****

***** NCSOStools: module NCFlatExt started *****

***** NCSOStools: module NCcycMin started *****

Input polynomial has (max) degree 6 and min degree 0.

Detected 22 monomials in 2 variables.

There are 127 monomials in 2 variables of degree at most 6.

Preprocessing the input polynomial ...

Constructing monomial vector with 15 monomials.

Computing cyclically equivalent products ... done.

Preparing linear constraints ...

Number of linear constraints: 37.

Starting SDP solver ...

...

Residual norm: 1.3316e-009

***** NCSOStools: module NCcycSos started *****

Input polynomial has (max) degree 6 and min degree 0.

Detected 22 monomials in 2 variables.

There are 127 monomials in 2 variables of degree at most 6.

Preprocessing the input polynomial ...

Using user's monomial vector with 15 monomials.

Computing cyclically equivalent products ... done.

Preparing linear constraints ...

Number of linear constraints: 37.

Starting SDP solver ...

...

Residual norm: 6.3112e-008

***** No SOHS decomposition was computed because of the .decomposition == 0 switch! *****

***** Polynomial has a flat extension *****

***** NCSOStools: module NCFlatExt completed *****

***** NCSOStools: module GNS started *****

found 4 linearly independent vectors ...

using corresponding columns of a matrix ...

using corresponding words in a cell of monomials ...

constructing final matrices ... done.

***** NCSOStools: module GNS completed *****

***** NCSOStools: module AWbd started *****

step 1 ... done.

step 2 ... done.

step 3 ... done.

***** NCSOStools: module AWbd completed *****

Number of simultaneously diagonalized blocks: 1

Evaluating block number: 1 ..... completed.

***** NCSOStools: module NCcycOpt completed *****

X = Columns 1 through 8

    -0.3281    0.0000   -0.0734   -0.9764    0.0000   -0.3281    0.9764   -0.0734

    -0.8803   -0.0000    0.0130    0.1724   -0.0000   -0.8803   -0.1724    0.0130

    Columns 9 through 16

    -0.0734    0.9764   -0.2759    0.0000   -0.9764   -0.0734    0.0000   -0.2759

     0.0130   -0.1724    1.1588   -0.0000    0.1724    0.0130   -0.0000    1.1588

f_min = 0.28421477

 

% We get a matrix X each of whose rows represent a square matrix

% A_i=reshape(X(i,:),4,4) that is a trace minimizer for f. The matrices A_i

% are simultaneously block diagonal. f_min represents the trace minimum of

% f; Each element in this vector equals the trace of the evaluation of f in

% equally positioned diagonal blocks consisting of matrices A_i.