Installer et compiler ces fichiers dans votre répertoire de travail.Installer ce fichier dans votre répertoire de travail.
![]() |
c3d1.c ' |
---|
/* --------------------------------- */
/* save as c3d1.c */
/* --------------------------------- */
#include "x_hfile.h"
#include "fd.h"
/* --------------------------------- */
int main(void)
{
int n = 6;
double FirstApproximation = 1.5;
clrscrn();
printf(" Use Newton's method to approximate \n"
" the largest positive real root of :\n\n"
" f : x-> %s\n\n\n"
" On a graph of f, you can see that, the largest\n"
" positive real root of f is between 1.0 and 2.0.\n\n"
" Choose x = %.1f as a first approximation.\n\n",
feq,FirstApproximation);
stop();
clrscrn();
printf(" As a first approximation x = %.1f \n\n"
" The Newton's method give : \n\n",FirstApproximation);
p_Newton_s_Method(FirstApproximation, n, f, Df);
printf(" f(%.15ff) = %.15f\n\n",
Newton_s_Method(FirstApproximation, n, f, Df)
,f(Newton_s_Method(FirstApproximation, n, f, Df)));
stop();
return 0;
}
Vous pouvez choisir votre logiciel de traçage de courbes pour pouvoir repérer les racines et ensuite faire juste un encadrement comme précédemment.
Exemple de sortie écran :
Use Newton's method to approximate
the largest positive real root of :
f : x-> x**3 - 3.0*x + 1.0
On a graph of f, you can see that, the largest
positive real root of f is between 1.0 and 2.0.
Choose x = 1.5 as a first approximation.
Press return to continue.
Exemple de sortie écran :
As a first approximation x = 1.5
The Newton's method give :
x[1] = 1.500000000000000
x[2] = 1.533333333333333
x[3] = 1.532090643274854
x[4] = 1.532088886241467
x[5] = 1.532088886237956
x[6] = 1.532088886237956
f(1.532088886237956f) = -0.000000000000000
Press return to continue.
Cet article est issu de Wikibooks. Le texte est sous licence Creative Commons - Attribution - Partage dans les Mêmes. Des conditions supplémentaires peuvent s'appliquer aux fichiers multimédias.