Sommaire

Installer et compiler ces fichiers dans votre répertoire de travail.

c16b.c
'
/* --------------------------------- */
/* save as c16b.c                    */
/* --------------------------------- */
#include "x_hfile.h"
#include      "fb.h"
/* --------------------------------- */
int main(void)
{
double  a  = 2;
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)/4  + (y**2)/9  - 1 = 0    
  | ((x-1)**2)/10 + ((y+1)**2)/5 - 1 = 0


 As a first approximation x = 2.0 y = 1.0 

 Press return to continue.

Exemple de sortie écran :

 n = 1 
 f(2.000000,1.000000) = +0.111111  
 g(2.000000,1.000000) = -0.100000

 n = 2 
 f(1.852941,1.161765) = +0.008314  
 g(1.852941,1.161765) = +0.007396

 n = 3 
 f(1.845967,1.154587) = +0.000018  
 g(1.845967,1.154587) = +0.000015

 n = 4 
 f(1.845952,1.154572) = +0.000000  
 g(1.845952,1.154572) = +0.000000

 Press return to continue.


Exemple de sortie écran :

 the solutions of the following system is :


         x = 1.845952  y = 1.154572  


 f(1.845952,1.154572) = 0.000000  
 g(1.845952,1.154572) = 0.000000

 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.