% Problem 1

sigma = [ 2 -3 4;  -3 -5 -6; 4 -6 2];

n = [0.6 -0.8 0]';

% a
p = sigma * n

pmag = norm(p)

% b

sig = n' * sigma * n

% c

tau = sqrt( pmag^2-sig^2)

% d

n1 = n

n2 = [0.8 0.6 0]'

n3 = [0 0 1]'

R = [ n1 n2 n3]

sigma_p = R' *sigma*R

% e

[V,D]=eigs(sigma)

sps = sort(diag(D))

s1 = sps(3)
s2 = sps(2)
s3 = sps(1)

% f

tau_max = .5*(s1-s3)

% g method 1

vec_o = 1/sqrt(3)*[ 1 1 1]'

pvec_o = D * vec_o
npvec_o = norm(pvec_o)

sn_o = vec_o' * D * vec_o

tau_o = sqrt( npvec_o^2 -sn_o^2)

% g method 2 - use formula

sn_oct = (s1+s2+s3)/3

tau_oct = 1/3*sqrt( (s1-s2)^2 + ...
           (s2-s3)^2 + (s1-s3)^2 )

% h

v_oct = V*vec_o


