function [WU,WS] = f_map(phi,p)

global oldS newS_f W

map = @(x)( phi(x+p)-p);

[V,D] = eig(Dapprox(map,p))

EU = V(:,1)
ES = V(:,2)


% Take u0 from EU
% 
% Form the segment!

e0(:,1) = -1e-6*EU;
e0(:,2) = +1e-6*EU;

e0(:,3) = -1e-6*ES;
e0(:,4) = +1e-6*ES;


c = {'r-','r-','b--','b--'};

figure;
for j=1:2

  j
  
  if(j > 2)
    map = @(x)( fsolve(@(s)( phi(s+p)-p-x ),[0;0]));
  end
  
  oldS = [e0(:,j)   map(e0(:,j))]
  
  for i=2:1:20
  
    newS  = [oldS(:,end-1) oldS(:,end)];
    abu   = oldS(:,1);
  
    k = 2
    
    while( k <= length(oldS) )
      
      % Yritetään muutosta !
     
      del =2*( oldS(:,k) - abu(:,end));
      
      ds    = 1;
      angle = 1;
      ref = -1;
      
      
      
      while( ( (ds > 0.1) | (angle>0.1) ) & (norm(del) > 1e-5)) 
      	
	del = del/2;
	ref =ref+1;
	
	newPoint = map( abu(:,end) + del);
	ds    = norm( newPoint - newS(:,end))
	angle = abs( acos( dot( newPoint - newS(:,end), newS(:,end) - newS(:,end-1))/(ds*norm(newS(:,end)-newS(:,end-1)))));
	
      end
        
      newS = [newS newPoint]
      abu  = [abu  abu(:,end)+del]  
      oldS
      
      if(not(ref))
	k = k+1;
      end
      
    end
    hold on;plot(newS(1,:),newS(2,:),c{j}); pause;
    oldS = newS
    abu =[];
  end
end


WU = [W{1} W{2}];
WS =[];
%WS = [W{3} W{4}];