%
%  matlab routine to invert the stress versus strain matrix
%
%  elastic constants
%
clear;
sxx=sym('sxx');
syy=sym('syy');
szz=sym('szz');
sxy=sym('sxy');
sxz=sym('sxz');
syz=sym('syz');
g = sym('g');
%
%  stress tensor
%
A=[sxx, sxy, sxz;
   sxy, syy, syz;
   sxz, syz  szz];
%
G=[g 0,0;
   0,g,0;
   0,0,g];
%
A-G
% 
% calculate the invariants
%
invar=det(A-G)
%
%  extract the invariants
%
I=sxx+syy+szz
II=sxy^2+sxz^2+syz^2-sxx*syy-sxx*szz-syy*szz
III = simplify(invar + g^3 - I*g^2 - II*g)
%
% confirm that III  id the determinant of A
%
simplify(det(A))
