Mathc initiation/Fichiers c : c24cc
Installer et compiler ces fichiers dans votre répertoire de travail.
![]() |
c16c.c |
---|
/* --------------------------------- */
/* save as c16c.c */
/* --------------------------------- */
#include "x_hfile.h"
#include "fc.h"
/* --------------------------------- */
int main(void)
{
double a = 3;
double b = 1;
pt2d p = {a,b};
int n = 4;
double h = .1;
clrscrn();
p = i_pt2d(a,b); /* For info */
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, h, p);
stop();
clrscrn();
p = newton_fxy( n, f, g, h, 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)/9 + (y**2)/4 - 1 = 0
| ((x-1)**2)/2 + ((y-1)**2)/3 - 1 = 0
As a first approximation x = 3.0 y = 1.0
Press return to continue.
Exemple de sortie écran :
n = 1
f(3.000000,1.000000) = +0.250000
g(3.000000,1.000000) = +1.000000
n = 2
f(2.500000,1.166667) = +0.034722
g(2.500000,1.166667) = +0.134259
n = 3
f(2.408444,1.194339) = +0.001123
g(2.408444,1.194339) = +0.004447
n = 4
f(2.405192,1.195374) = +0.000001
g(2.405192,1.195374) = +0.000006
Press return to continue.
Exemple de sortie écran :
the solutions of the following system is :
x = 2.405192 y = 1.195374
f(2.405192,1.195374) = 0.000001
g(2.405192,1.195374) = 0.000006
Press return to continue.