arctan := proc(x)
local s, v, q, w;
	s := 10**iquo(-Digits,2);
	v := x / (1 + sqrt(1+x*x));
	q := 1;
	while 1-s > 10**(-Digits) do
		q := 2*q / (1+s);
		w := 2*s*v / (1+v*v);
		w := w / (1 + sqrt(1-w*w));
		w := (v+w) / (1-v*w);
		v := w / (1 + sqrt(1+w*w));
		s := evalr( 2*sqrt(s) / (1+s) )
		od;
q * ln( (1+v)/(1-v) )
end;

arctan( 0.5 );
