% Sitzung_S143
% for a more sophisticated version see file "session.m"

format long;

function [c,err]=p5solve(z)
  for p=1:4, A(:,p)=z.^(p-1); end
  b=isgamma(z); d=sign(b-A*(A\b)); c=[A d]\b; err=c(5); c(5)=[];
endfunction
function y=epsilon(th)
  z=z=exp(i*th); z=[z;-1;conj(z)]; [c,e]=p5solve(z); y=real(e);
endfunction
th=[80;130]*pi/180; f0=epsilon(th);
while true,
   dth=hessian('epsilon',th)\cjac('epsilon',th)';
   new=th-dth; f1=epsilon(new);
   [new' f1], if abs(f1-f0)<1e-15, break; end
   f0=f1; th=new;
end