Approximating a square root
$target = 81;
$guess = 1.0;
$precision = 0.0000001;
$guess_squared = $guess * $guess;
while (($guess_squared - $target > $precision) or ($guess_squared - $target < - $precision))
{
print("Current guess: $guess is the square root of $target
");
$guess = ($guess + ($target / $guess)) / 2;
$guess_squared = $guess * $guess;
}
print("$guess squared = $guess_squared
");
?>