Mathc initiation/Fichiers c : c24ca
Installer et compiler ces fichiers dans votre répertoire de travail.
c16a.c |
---|
/* --------------------------------- */
/* save as c16a1.c */
/* --------------------------------- */
#include "x_hfile.h"
#include "fa.h"
/* --------------------------------- */
int main(void)
{
double a = -.5;
double b = -.5;
pt2d p = {a,b}; /* initialize first method */
int n = 5;
clrscrn();
p = i_pt2d(a,b); /* initialize second method */
printf(" Use Newton's method to approximate, \n");
printf(" the solutions of the following system :\n\n\n");
printf(" | %s = 0 \n", feq);
printf(" | %s = 0\n\n\n", geq);
printf(" As a first approximation x = %.1f y = %.1f \n\n", a, b);
stop();
clrscrn();
p_newton_fxy( n, f, g, p);
stop();
clrscrn();
p = newton_fxy( n, f, g, p);
printf(" the solutions of the following system is :\n\n\n");
printf(" x = %f y = %f \n\n\n",p.x,p.y);
printf(" f(%f,%f) = %f \n",p.x,p.y, f(p.x, p.y));
printf(" g(%f,%f) = %f\n\n",p.x,p.y, g(p.x,p.y) );
stop();
return 0;
}
/* --------------------------------- */
/* --------------------------------- */
Voir le fichier x_nwtn.h pour étudier l'algorithme.
Exemple de sortie écran :
Use Newton's method to approximate,
the solutions of the following system :
| x**2 + y**2 - 1 = 0
| y - sin(x) = 0
As a first approximation x = 0.5 y = 0.5
Press return to continue.
Exemple de sortie écran :
x1 =-0.500000 y1 =-0.500000
delta_p.x1 =-0.277258 delta_p.y1 =-0.222742
x2 =-0.777258 y2 =-0.722742
delta_p.x2 =+0.036957 delta_p.y2 =+0.047759
x3 =-0.740301 y3 =-0.674983
delta_p.x3 =+0.001214 delta_p.y3 =+0.001369
x4 =-0.739086 y4 =-0.673613
delta_p.x4 =+0.000001 delta_p.y4 =+0.000001
x5 =-0.739085 y5 =-0.673612
Press return to continue.
Exemple de sortie écran :
the solutions of the following system is :
x = 0.739085 y = 0.673612
f(0.739085,0.673612) = 0.000003
g(0.739085,0.673612) = 0.000002
Press return to continue.