% BAD_DYN_SYS  Illustrate a small (2 variable) dynamical system for which all 
%   formulas in the numerical computation treat both variables the same
%   (symmetrically) but for which the instability of the dynamical system
%   actually creates an asymmetry in the output merely from changing the
%   sequence of floating point operations.

format long 

disp('symmetric dynamical system with same floating point order:')
x = 1; y = 1;
disp([x y])
for j=1:15
  xnew = 10 * x - 9 * y + cos(x);
  ynew = - 9 * x + 10 * y + cos(y);
  x = xnew; y = ynew;
  disp([x y])
end

disp('symmetric dynamical system with slightly-different floating point order:')
x = 1; y = 1;
disp([x y])
for j=1:15
  xnew = 10 * x - 9 * y + cos(x);
  ynew = - 9 * x + cos(y) + 10 * y;
  x = xnew; y = ynew;
  disp([x y])
end

