function ShowMixed(A1,P1,phi1,A2,P2,phi2,SDSteps,NSteps)

%% showmixed() ?
%
%  Pre:  (A1,P1,phi1) and (A2,P2,phi2) are orbits.
%        SDSteps = number of steepest descent steps.
%        NSteps  = number of Newton Steps
%
%  Post: Applies steepest descent with 
%        with line searches to the sep function. The Full
%        Newton steps follow.
%
%  Usage: ShowMixed(10,2,pi/8,4,1,-pi/7,2,10)
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'showmixed():\n' );

   close all
   plist = [A1 P1 phi1 A2 P2 phi2];
  
   Lmax = 1;           % Max line step 
   con_size = 20;      % Size of the contour plot
  
  
   % Plot the two orbits.
  
   figure
   t=linspace(0,2*pi);
   Orbit(t,A1,P1,phi1,'-');
   hold on
   Orbit(t,A2,P2,phi2,'--');
   hold off

   % Display contours of the sep function.
  
   tRange = linspace(0,2*pi,con_size);
   Z = zeros(con_size,con_size);
   for i=1:con_size
      for j=1:con_size
	     t = [tRange(j);tRange(i)];
	     Z(i,j) = Sep(t,plist);
      end
   end
   figure
   C = contour(tRange,tRange,Z,10);
   title('Enter Contour Labels (Optional). To quit, strike <return>.')
   xlabel('t1')
   ylabel('t2')
   Clabel(C,'manual') 
  
   % Get ready for the iteration.
  
   title('Enter Starting Point for Steepest Descent')
   tc = zeros(2,1);
   [tc(1),tc(2)] = ginput(1);
   fc = Sep(tc,plist);
   gc = gSep(tc,plist);
   tvals = tc;
   fvals = fc;
   gvals = norm(gc);
   title('')
  
   % Steepest Descent with line search:
  
   clc
   
   disp('Step     sep              t(1)                 t(2)          norm(grad)')
   disp('---------------------------------------------------------------------')
   disp(sprintf('%2.0f %10.6f     %18.15f   %18.15f    %5.1e ',0,fc,tc,norm(gc)))
   figure(3)
   
   for step = 1:SDSteps    
	  [tnew,fnew,gnew] = SDStep('Sep','gSep',tc,fc,gc,plist,Lmax,0);      
	  tvals = [tvals tnew];       tc = tnew;
	  fvals = [fvals fnew];       fc = fnew;
	  gvals = [gvals norm(gnew)]; gc = gnew;
	  disp(sprintf('%2.0f %10.6f     %18.15f   %18.15f    %5.1e ',step,fc,tc,norm(gc)))
   end
   
   [gc,Hc] = gHSep(tc,plist);
   for step=SDSteps+1:SDSteps+NSteps;
      tc = tc - Hc\gc;
	  [gc,Hc] = gHSep(tc,plist);
	  fc = Sep(tc,plist);	  
	  tvals = [tvals tc];       
	  fvals = [fvals fc];      
	  gvals = [gvals norm(gc)]; 
	  disp(sprintf('%2.0f %10.6f     %18.15f   %18.15f    %5.1e ',step,fc,tc,norm(gc)))
	end
  
   % Show solution on orbit plot:
  
    
   figure(1)
   hold on
   last = length(gvals); 
   Orb1 = Orbit(tvals(1,last),A1,P1,phi1,'*');
   Orb2 = Orbit(tvals(2,last),A2,P2,phi2,'*');
   plot([Orb1(1) Orb2(1)],[Orb1(2) Orb2(2)])
   title(sprintf('min Sep = %8.4f',fvals(last)))
   hold off
  
   % Show the descent path on the contour plot:
  
   figure(2)
   hold on
   plot(tvals(1,:),tvals(2,:),tvals(1,1),tvals(2,1),'o')
   hold off
   title(sprintf('tmin = (%8.3f,%8.3f)   norm(gmin)= %8.4e',tvals(1,last),tvals(2,last),gvals(last)))
  
 
   % Plot the descent of the sep and its gradient:
  
   figure(4)
   subplot(2,1,1)
   plot(fvals)
   title('Value of Sep')
   xlabel('Iteration')
   subplot(2,1,2)
   semilogy(gvals)
   title('Value of norm(gSep).')
   xlabel('Iteration')
  
  return
end

