<?php $r = 4; $tochnost = 1000000; function y($x) { global $r; return sqrt($r*$r-$x*$x); } for($i=-$r*$tochnost;$i<$r*$tochnost;$i++) { $x1 = $i/$tochnost; $y1 = y($x1); $x2 = ($i+1)/$tochnost; $y2 = y($x2); $d += sqrt(pow(($x2-$x1),2)+pow(($y2-$y1),2)); } echo 'pi = '.$d/$r; ?>