Mathc initiation/c57a1
Installer ce fichier dans votre répertoire de travail.
/* save as x_hfile.h */
/* ---------------------------------- */
 Déclaration des fichiers h.

Mathc initiation/c57a2
Installer ce fichier dans votre répertoire de travail.
/* save as x_def.h */
void clrscrn(void)
 printf("\n\n\n\n\n\n\n\n\n\n\n"
 "\n\n\n\n\n\n\n\n\n\n\n"
 "\n\n\n\n\n\n\n\n\n\n\n");
/* ---------------------------------- */
void stop(void)
 printf(" Press return to continue. ");
 getchar();
/* ---------------------------------- */
 Déclaration des fichiers h.

Mathc initiation/c57a3
Installer ce fichier dans votre répertoire de travail.
/* save as x_dxdy.h */
double int_dx(
double (*P_f)(double x, double y),
double (*P_u)(double y),
double (*P_v)(double y),
 int n,
double y
 int i = 0;
double m = 0.;
double M = 0.;
 for(i = 0; i <= n; i++)
 M += m * (*P_f)(((*P_u)(y)) + i*(((*P_v)(y))-((*P_u)(y)))/n, y);
 return( ((((*P_v)(y)) -((*P_u)(y)))*M) / (3*n) );
/* ---------------------------------- */
double simpson_dxdy(
double (*P_f)(double x, double y),
double (*P_u)(double y),
double (*P_v)(double y),
 int n,
double ay,
double by,
 int ny
 int i = 0;
double m = 0.;
double M = 0.;
 for(i = 0; i <= ny; i++)
 M += m * int_dx((*P_f), (*P_u),(*P_v),n,(ay+i*(by-ay)/ny));
 return( ((by-ay)*M) / (3*ny) );
/* ---------------------------------- */
 Déclaration des fichiers h.

Mathc initiation/c57a4
Installer ce fichier dans votre répertoire de travail.
/* save as x_dydx.h */
double int_dy(
double (*P_f)(double x, double y),
double x,
double (*P_u)(double x),
double (*P_v)(double x),
 int ny
 int i = 0;
double m = 0.;
double M = 0.;
 for(i = 0; i <= ny; i++)
 M += m * (*P_f)(x, ((*P_u)(x)) + i*(((*P_v)(x))-((*P_u)(x)))/ny);
 return( ((((*P_v)(x)) -((*P_u)(x)))*M) / (3*ny) );
/* ---------------------------------- */
double simpson_dydx(
double (*P_f)(double x, double y),
double a,
double b,
 int n,
double (*P_u)(double x),
double (*P_v)(double x),
 int ny)
 int i = 0;
double m = 0.;
double M = 0.;
 for(i = 0; i <= n; i++)
 M += m * int_dy((*P_f),(a + i*(b-a)/n), (*P_u),(*P_v),ny);
 return( ((b -a)*M) / (3*n) );
/* ---------------------------------- */
 Déclaration des fichiers h.

Mathc initiation/c57ba
Installer ce fichier dans votre répertoire de travail.
/* save as fa.h */
double f(
double x,
double y)
 return( (x + y) );
/* --------------------------------- */
char feq[] = "x + y";
/* --------------------------------- */
double u(
double x)
 return( ( 0) );
/* --------------------------------- */
char ueq[] = "0";
/* --------------------------------- */
double v(
double x)
 return( sqrt(x) );
/* --------------------------------- */
char veq[] = "sqrt(x)";
/* --------------------------------- */
double g(
double x,
double y)
 return( x* (x + y) );
/* --------------------------------- */
char geq[] = "x* (x + y)";
/* --------------------------------- */
double h(
double x,
double y)
 return( y* (x + y) );
/* --------------------------------- */
char heq[] = "y* (x + y)";
/* --------------------------------- */
 Déclaration des fichiers h.

Mathc initiation/c57bb
Installer ce fichier dans votre répertoire de travail.
/* save as fb.h */
double f(
double x,
double y)
 return( (x) );
/* --------------------------------- */
char feq[] = "x";
/* --------------------------------- */
double u(
double y)
 return( (y*y) );
/* --------------------------------- */
char ueq[] = "y**2";
/* --------------------------------- */
double v(
double y)
 return( (4) );
/* --------------------------------- */
char veq[] = "4";
/* --------------------------------- */
double g(
double x,
double y)
 return (x* (x) );
/* --------------------------------- */
char geq[] = "x* x";
/* --------------------------------- */
double h(
double x,
double y)
 return (y* (x) );
/* --------------------------------- */
char heq[] = "y* x";
/* --------------------------------- */
 Déclaration des fichiers h.

Mathc initiation/c57bc
Installer ce fichier dans votre répertoire de travail.
/* save as fc.h */
double f(
double x,
double y)
 return( (4) );
/* --------------------------------- */
char feq[] = "4";
/* --------------------------------- */
double u(
double x)
 return( (1./2.) );
/* --------------------------------- */
char ueq[] = "1./2.";
/* --------------------------------- */
double v(
double x)
 return( 1/cos(x) );
/* --------------------------------- */
char veq[] = "1/cos(x)";
/* --------------------------------- */
double g(
double x,
double y)
 return( x* (4) );
/* --------------------------------- */
char geq[] = "x* (4)";
/* --------------------------------- */
double h(
double x,
double y)
 return( y* (4) );
/* --------------------------------- */
char heq[] = "y* (4)";
/* --------------------------------- */
 Déclaration des fichiers h.

Mathc initiation/c57ca
Installer et compiler ces fichiers dans votre répertoire de travail.
/* save as c17a.c */
int main(void)
double a = 0;
double b = 9;
int n = 2*20;
int ny = 2*20;
double m = 0;
double Mx= 0;
double My= 0;
 clrscrn();
 printf(" Find the mass and the center of mass of the lamina\n");
 printf(" that has the shape of the region bounded by the \n");
 printf(" graphs of the given equations.\n\n");
 printf(" y = sqrt(x), x = 9, y = 0, \n\n");
 printf(" and f(x,y) (the area mass density at (x,y)) \n\n");
 printf(" f : (x,y)-> %s \n\n", feq);
 printf(" These give : \n\n");
 printf(" b : %+.1f \n", b);
 printf(" a : %+.1f \n\n", a);
 printf(" u : (x)-> %s \n", ueq);
 printf(" v : (x)-> %s \n\n", veq);
 stop();
 clrscrn();
 m = simpson_dydx(f,a,b,n,u,v,ny);
 printf(" Compute the mass m.\n");
 printf(" (b (v(x)\n");
 printf(" m = int( int( f(x,y) dy dx = %.1f\n", m);
 printf(" (a (u(x)\n\n");
 Mx = simpson_dydx(h,a,b,n,u,v,ny);
 printf(" Compute the moment Mx.\n");
 printf(" (b (v(x)\n");
 printf(" Mx = int( int( y f(x,y) dy dx = %.1f\n", Mx);
 printf(" (a (u(x)\n\n");
 My = simpson_dydx(g,a,b,n,u,v,ny);
 printf(" Compute the moment My.\n");
 printf(" (b (v(x)\n");
 printf(" My = int( int( x f(x,y) dy dx = %.1f\n", My);
 printf(" (a (u(x)\n\n");
 printf(" The center of mass is (X,Y)\n\n");
 printf(" X = My/m = %.2f Y = Mx/m = %.2f\n\n",My/m,Mx/m);
 stop();
 return 0;
/* --------------------------------- */
En mécanique, le centre de masse d'une plaque homogène est le point par rapport auquel la masse est uniformément répartie. Pratiquement, dans le cas d'un champ de pesanteur uniforme le centre de masse est confondu avec le centre de gravité de la plaque.
 Calculons le centre de masse d'une plaque non homogène.
Exemple de sortie écran :
 Find the mass and the center of mass of the lamina
 that has the shape of the region bounded by the 
 graphs of the given equations.
 y = sqrt(x), x = 9, y = 0, 
 and f(x,y) (the area mass density at (x,y)) 
 f : (x,y)-> x + y 
 These give : 
 b : +9.0 
 a : +0.0 
 u : (x)-> 0 
 v : (x)-> sqrt(x) 
 Press return to continue. 
Exemple de sortie écran :
 Compute the mass m.
 (b (v(x)
 m = int( int( f(x,y) dy dx = 117.5
 (a (u(x)
 Compute the moment Mx.
 (b (v(x)
 Mx = int( int( y f(x,y) dy dx = 153.9
 (a (u(x)
 Compute the moment My.
 (b (v(x)
 My = int( int( x f(x,y) dy dx = 746.4
 (a (u(x)
 The center of mass is (X,Y)
 X = My/m = 6.35 Y = Mx/m = 1.31
 Press return to continue.