<html> <body> <table> <tbody> <tr> <td> <?php
/* Données */ $a = 0; $b = 1; $eps = 1.e-8; function f($x){ return (($x-4)*$x-20)*$x+1; } /* Bissection */ echo "<p><b>Un zéro de la fonction <i>f</i> dans l'intervalle [".$a.", ".$b."]</b></p>"; $fa = f($a); $fb = f($b); if ($fa*$fb > 0) { echo "L'hypothèse f(a)*f(b) <= 0 n'est pas satisfaite"; } else { $c = ($a+$b)*0.5; $d = ($b-$a)*0.5; while ($d > $eps) { $fc = f ($c); if ($fa*$fc <= 0) { $b = $c; $fb = $fc; } else { $a = $c; $fa = $fc; } $c = ($a+$b)*0.5; $d = ($b-$a)*0.5; echo number_format($c,9)." ± " .number_format($d,9)."<br>"; } } echo "<p>Valeur précise à 16 chiffres = 0.04951570905559387</p>";
?> </td> </tr> </tbody> </table> </body> </html>