InputMatrix3aa := Matrix(3, 3, {(1, 1) = xx, (1, 2) = 283.6, (1, 3) = 285.4, (2, 1) = 283.6, (2, 2) = 285.4, (2, 3) = 0, (3, 1) = 285.4, (3, 2) = 0, (3, 3) = 0});

InputMatrix3 := Matrix(3, 3, {(1, 1) = 283.6, (1, 2) = 285.4, (1, 3) = 283.0, (2, 1) = 285.4, (2, 2) = 283.0, (2, 3) = 0, (3, 1) = 283.0, (3, 2) = 0, (3, 3) = 0});

InputMatrix3b := Matrix(3, 3, {(1, 1) = 285.4, (1, 2) = 283.0, (1, 3) = 287.6, (2, 1) = 283.0, (2, 2) = 287.6, (2, 3) = 0, (3, 1) = 287.6, (3, 2) = 0, (3, 3) = 0});

InputMatrix3c := Matrix(3, 3, {(1, 1) = 283.0, (1, 2) = 287.6, (1, 3) = 296.6, (2, 1) = 287.6, (2, 2) = 296.6, (2, 3) = 0, (3, 1) = 296.6, (3, 2) = 0, (3, 3) = 0});

InputMatrix3d := Matrix(3, 3, {(1, 1) = 287.6, (1, 2) = 296.6, (1, 3) = 286.2, (2, 1) = 296.6, (2, 2) = 286.2, (2, 3) = 0, (3, 1) = 286.2, (3, 2) = 0, (3, 3) = 0});

Old_Asso_eigenvector0 := Eigenvectors(MatrixMatrixMultiply(Transpose(InputMatrix3aa), InputMatrix3aa)):

Old_Asso_eigenvector1 := Eigenvectors(MatrixMatrixMultiply(Transpose(InputMatrix3), InputMatrix3)):

Old_Asso_eigenvector2 := Eigenvectors(MatrixMatrixMultiply(Transpose(InputMatrix3b), InputMatrix3b)):

Old_Asso_eigenvector3 := Eigenvectors(MatrixMatrixMultiply(Transpose(InputMatrix3c), InputMatrix3c)):

Old_Asso_eigenvector4 := Eigenvectors(MatrixMatrixMultiply(Transpose(InputMatrix3d), InputMatrix3d)):

#AA2 := MatrixMatrixMultiply(Old_Asso_eigenvector3[2], MatrixInverse(Old_Asso_eigenvector2[2]));

#AA3 := MatrixMatrixMultiply(Old_Asso_eigenvector4[2], MatrixInverse(Old_Asso_eigenvector3[2]));

AA2 := MatrixMatrixMultiply(Old_Asso_eigenvector2[2], MatrixInverse(Old_Asso_eigenvector1[2]));

AA3 := MatrixMatrixMultiply(Old_Asso_eigenvector3[2], MatrixInverse(Old_Asso_eigenvector2[2]));

sol11 := solve([Re(AA2[1][1]) = sin(m*2+phi), Re(AA3[1][1]) = sin(m*3+phi)], [m,phi]);

if nops(sol11) > 1 then

sol11 := sol11[1];

end if:

sin(rhs(sol11[1])+rhs(sol11[2]));

sol12 := solve([Re(AA2[1][2]) = sin(m*2+phi), Re(AA3[1][2]) = sin(m*3+phi)], [m,phi]);

if nops(sol12) > 1 then

sol12 := sol12[1];

end if:

sin(rhs(sol12[1])+rhs(sol12[2]));

sol13 := solve([Re(AA2[1][3]) = sin(m*2+phi), Re(AA3[1][3]) = sin(m*3+phi)], [m,phi]);

if nops(sol13) > 1 then

sol13 := sol13[1];

end if:

sin(rhs(sol13[1])+rhs(sol13[2]));

#*************************************

sol21 := solve([Re(AA2[2][1]) = sin(m*2+phi), Re(AA3[2][1]) = sin(m*3+phi)], [m,phi]);

if nops(sol21) > 1 then

sol21 := sol21[1];

end if:

sin(rhs(sol21[1])+rhs(sol21[2]));

sol22 := solve([Re(AA2[2][2]) = sin(m*2+phi), Re(AA3[2][2]) = sin(m*3+phi)], [m,phi]);

if nops(sol22) > 1 then

sol22 := sol22[1];

end if:

sin(rhs(sol22[1])+rhs(sol22[2]));

sol23 := solve([Re(AA2[2][3]) = sin(m*2+phi), Re(AA3[2][3]) = sin(m*3+phi)], [m,phi]);

if nops(sol23) > 1 then

sol23 := sol23[1];

end if:

sin(rhs(sol23[1])+rhs(sol23[2]));

#**************************************

sol31 := solve([Re(AA2[3][1]) = sin(m*2+phi), Re(AA3[3][1]) = sin(m*3+phi)], [m,phi]);

if nops(sol31) > 1 then

sol31 := sol31[1];

end if:

sin(rhs(sol31[1])+rhs(sol31[2]));

sol32 := solve([Re(AA2[3][2]) = sin(m*2+phi), Re(AA3[3][2]) = sin(m*3+phi)], [m,phi]);

if nops(sol32) > 1 then

sol32 := sol32[1];

end if:

sin(rhs(sol32[1])+rhs(sol32[2]));

sol33 := solve([Re(AA2[3][3]) = sin(m*2+phi), Re(AA3[3][3]) = sin(m*3+phi)], [m,phi]);

if nops(sol33) > 1 then

sol33 := sol33[1];

end if:

sin(rhs(sol33[1])+rhs(sol33[2]));

#****************************************************

AAA1 := Matrix([[sin(rhs(sol11[1])+rhs(sol11[2])),sin(rhs(sol12[1])+rhs(sol12[2])),sin(rhs(sol13[1])+rhs(sol13[2]))],[sin(rhs(sol21[1])+rhs(sol21[2])),sin(rhs(sol22[1])+rhs(sol22[2])),sin(rhs(sol23[1])+rhs(sol23[2]))],[sin(rhs(sol31[1])+rhs(sol31[2])),sin(rhs(sol32[1])+rhs(sol32[2])),sin(rhs(sol33[1])+rhs(sol33[2]))]]);

MA := MatrixMatrixMultiply(Transpose(InputMatrix3aa), InputMatrix3aa) - lambda*IdentityMatrix(3):

eignvalues1 := evalf(solve(Determinant(MA), lambda)):

MA1 := MatrixMatrixMultiply(Transpose(InputMatrix3aa), InputMatrix3aa) - eignvalues1[1]*IdentityMatrix(3):

MA2 := MatrixMatrixMultiply(Transpose(InputMatrix3aa), InputMatrix3aa) - eignvalues1[2]*IdentityMatrix(3):

MA3 := MatrixMatrixMultiply(Transpose(InputMatrix3aa), InputMatrix3aa) - eignvalues1[3]*IdentityMatrix(3):

eigenvector1 := LinearSolve(MA1,<x,y,z>):

eigenvector2 := LinearSolve(MA2,<x,y,z>):

eigenvector3 := LinearSolve(MA3,<x,y,z>):

MR := MatrixMatrixMultiply(AAA1, Matrix([[Re(eigenvector1[1]),Re(eigenvector2[1]),Re(eigenvector3[1])],[Re(eigenvector1[2]),Re(eigenvector2[2]),Re(eigenvector3[2])],[Re(eigenvector1[3]),Re(eigenvector2[3]),Re(eigenvector3[3])]]));

ML := Re(Old_Asso_eigenvector1[2]);

solve(ML[1][1] = MR[1][1], xx);

with(Optimization):

Minimize(ML[1][1] - MR[1][1], {0 <= xx}, assume = nonnegative);

Error, (in Optimization:-NLPSolve) abs is not differentiable at non-real arguments;