format compact
clear all
m_nom = [0.260; 0.196; 0.544];
m_reopt = [0.200; 0.075; 0.725];
pert = 0.1;
for i = 1:4
  A = [ 1   1   1   1;
       99 105  95  99;
       0   0   0   1;
       1   0   0   0];
 
  b = [ 1, 98, 0, m_nom(1)+pert]';
  m = inv(A)*b;


  dm = 0.01; % Implementation error
  disp('----------------------------------')
  if i == 1
    disp('m1 constant')
    G = (m(1)-m_nom(1))/pert;
    span_y = abs(m_reopt(1)-m_nom(1))+dm;
  elseif i == 2
    disp('m2 constant')
    G = (m(2)-m_nom(2))/pert;
    span_y = abs(m_reopt(2)-m_nom(2))+dm;
  elseif i == 3
    disp('m3 constant')
    G = (m(3)-m_nom(3))/pert;
    span_y = abs(m_reopt(3)-m_nom(3))+dm;
  elseif i == 4
    disp('m1-0.5m2 constant')
    G = ((m(1)-0.5*m(2))-(m_nom(1)-0.5*m_nom(2)))/pert;
    span_y = abs((m_reopt(1)-0.5*m_reopt(2))-(m_nom(1)-0.5*m_nom(2)))+1.5*dm;
  end
  G = G
  span_y = span_y
  Gs = G/span_y
  LossFactor = 1/Gs^2
end
