program assignment5_2;

var i, phi:real;
    j, R:integer;



function f(phi:real):real; far;
begin
  f:=i*cos(phi)-phi;
end;



type funcparam = function(x:real):real;

procedure bisection(func:funcparam; x1, x2, eps:real; var x:real);
var x3, res:real;

begin

  x3:=(x1+x2)/2;

  res:=func((x1+x2)/2);

  if abs(res)<eps then x:=x3
  else begin

    if (func(x1)*res<0) then x2:=x3
    else x1:=x3;

    bisection(func, x1, x2, eps, x);

  end;

end;



begin

  writeln(' i (A norm) | phi (rad) ');
  writeln('------------+-----------');
  writeln('    0.0     |  0.00000  ');

  for j:=1 to 20 do begin

    i:=j/5;

    bisection(@f, 0, Pi()/2, 1E-6, phi);

    writeln('    ',i:3:1,'     |  ',phi:7:5);

  end;

  writeln();
  write('Press any key to continue.');
  readln;

end.
