Aller au contenu

Mathc initiation/Fichiers c : c24cc

Un livre de Wikilivres.


Sommaire

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

c16c.c
/* --------------------------------- */
/* save as c16c1.c                   */
/* --------------------------------- */
#include "x_hfile.h"
#include      "fc.h"
/* --------------------------------- */
int main(void)
{

double  a = 3;
double  b = 1;
pt2d    p = {a,b}; /* initialize first method */
int     n = 6;

 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)/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 :

 x1		    =+3.000000		  y1		    =+1.000000
 delta_p.x1	=-0.500000		  delta_p.y1	=+0.166667

 x2		    =+2.500000		  y2		    =+1.166667
 delta_p.x2	=-0.091556		  delta_p.y2	=+0.027672

 x3		    =+2.408444		  y3		    =+1.194339
 delta_p.x3	=-0.003252		  delta_p.y3	=+0.001035

 x4		    =+2.405192		  y4		    =+1.195374
 delta_p.x4	=-0.000004		  delta_p.y4	=+0.000001

 x5		    =+2.405188		  y5		    =+1.195375
 delta_p.x5	=-0.000000		  delta_p.y5	=+0.000000

 x6		    =+2.405188		  y6		    =+1.195375 

 Press return to continue.


Exemple de sortie écran :

 the solutions of the following system is :


         x = 2.405188  y = 1.195375  


 f(2.405188,1.195375) = 0.000000  
 g(2.405188,1.195375) = -0.000000

 Press return to continue.