<html> <body> <table> <tbody> <tr> <td> <?php
/* Données */ $x0 = 0.5; function f($x){ return (($x-4)*$x-20)*$x+1; } function df($x){ return (3*$x-8)*$x-20; } /* Méthode de Newton */ echo "<p><b>Un zéro de la fonction <i>f</i> calculé par la méthode de Newton</b></p>"; $x1 = $x0 - f($x0)/df($x0); if ($x0 < $x1) { do { $x0=$x1; $x1 = $x0 - f($x0)/df($x0); echo $x0."<br>"; } while($x0 < $x1); } else { do { $x0=$x1; $x1 = $x0 - f($x0)/df($x0); echo $x0."<br>"; } while($x0 > $x1); } echo "<p>Valeur précise à 16 chiffres = 0.04951570905559387</p>";
?> </td> </tr> </tbody> </table> </body> </html>