% P3
  disp(' ')
  disp('*************************************')
  disp(' ')
  disp(' Problem 3')
  disp(' ')
  
% First Example
  n = 10;
  randn('seed',0)
  x = randn(n,1); x = x/norm(x); [z,idx] = sort(abs(x));  x = x(idx);
  y = randn(n,1); y = y/norm(y); [z,idy] = sort(-abs(y)); y = y(idy);
 
  [c,s] = Rotate(x,y);
  z = x;
  for k=n-1:-1:1
     z(k:k+1) = [c(k) s(k);-s(k) c(k)]*z(k:k+1);
  end
  disp(sprintf('Eg1: norm(z-y) = %5.2e',norm(z-y)))
  
  x(1) = -x(1);
  [c,s] = Rotate(x,y);
  z = x;
  for k=n-1:-1:1
     z(k:k+1) = [c(k) s(k);-s(k) c(k)]*z(k:k+1);
  end
  disp(sprintf('Eg2: norm(z-y) = %5.2e',norm(z-y)))
  
% Second Example
  x = [ 1 ; 2] ; x = x/norm(x) ; 
  y = [ 4 ; 3] ; y = y/norm(y) ;
  [c,s] = Rotate(x,y);
  z = [c s;-s c]*x;
  disp(sprintf('Eg3: norm(z-y) = %5.2e    |c^2+s^2-1| = %5.2e  ',norm(z-y),abs(c^2+s^2-1)))
  
% Third Example
  x = [ 1 ; -2] ; x = x/norm(x) ; 
  y = [ 4 ; 3] ; y = y/norm(y) ;
  [c,s] = Rotate(x,y);
  z = [c s;-s c]*x;
  disp(sprintf('Eg3: norm(z-y) = %5.2e    |c^2+s^2-1| = %5.2e  ',norm(z-y),abs(c^2+s^2-1)))
  
% Fourth Example
  x = [ 1 ; 2] ; x = x/norm(x) ; 
  y = [ -4 ; 3] ; y = y/norm(y) ;
  [c,s] = Rotate(x,y);
  z = [c s;-s c]*x;
  disp(sprintf('Eg4: norm(z-y) = %5.2e    |c^2+s^2-1| = %5.2e  ',norm(z-y),abs(c^2+s^2-1)))
  
% Fifth Example
  x = [ 1 ; -2] ; x = x/norm(x) ; 
  y = [ 4 ; -3] ; y = y/norm(y) ;
  [c,s] = Rotate(x,y);
  z = [c s;-s c]*x;
  disp(sprintf('Eg5: norm(z-y) = %5.2e    |c^2+s^2-1| = %5.2e  ',norm(z-y),abs(c^2+s^2-1)))
  
% Sixth Example
  x = [ -1 ; 2] ; x = x/norm(x) ; 
  y = [ -4 ; 3] ; y = y/norm(y) ;
  [c,s] = Rotate(x,y);
  z = [c s;-s c]*x;
  disp(sprintf('Eg6: norm(z-y) = %5.2e    |c^2+s^2-1| = %5.2e  ',norm(z-y),abs(c^2+s^2-1)))
  
% Seventh Example
  x = [ 0 ; 0 ; 1] ; 
  y = [ 1 ; 0;  0] ; 
  [c,s] = Rotate(x,y);
  x(2:3) = [c(2) s(2);-s(2) c(2)]*x(2:3);
  x(1:2) = [c(1) s(1);-s(1) c(1)]*x(1:2);
  disp(sprintf('Eg7: norm(z-y) = %5.2e   ',norm(x-y)))
  

 
 
 
 