Aller au contenu

Mathc initiation/Fichiers c : c24cb

Un livre de Wikilivres.


Sommaire

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

c16b.c
/* --------------------------------- */
/* save as c16b1.c                   */
/* --------------------------------- */
#include "x_hfile.h"
#include      "fb.h"
/* --------------------------------- */
int main(void)
{
double  a = -2;
double  b = 0;
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)/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 :

 x1		    =-2.000000		  y1	    	=+0.000000
 delta_p.x1	=-0.000000		  delta_p.y1	=-0.250000

 x2		    =-2.000000		  y2		    =-0.250000
 delta_p.x2	=+0.008333		  delta_p.y2	=-0.025000

 x3		    =-1.991667		  y3	    	=-0.275000
 delta_p.x3	=+0.000102		  delta_p.y3	=-0.000244

 x4		    =-1.991565		  y4		    =-0.275244
 delta_p.x4	=+0.000000		  delta_p.y4	=-0.000000

 x5		    =-1.991565		  y5	    	=-0.275244

 Press return to continue.


Exemple de sortie écran :

 the solutions of the following system is :


         x = -1.991565  y = -0.275244  


 f(-1.991565,-0.275244) = -0.000000  
 g(-1.991565,-0.275244) = 0.000000

 Press return to continue.