Mathc initiation/c57cb
Installer et compiler ces fichiers dans votre répertoire de travail.
/* save as c17b.c */
int main(void)
double ay = -2;
double by = 2;
int ny = 2*20;
int nx = 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(" x = y**2, x = 4, \n\n");
 printf(" and if f(x,y), the area mass density at the point P(x,y), \n");
 printf(" is directly proportional to the distance from the y-axis to P\n\n");
 printf(" f : (x,y)-> %s \n\n", feq);
 printf(" These give : \n\n");
 printf(" by : %+.1f \n", by);
 printf(" ay : %+.1f \n\n", ay);
 printf(" u : (y)-> %s \n", ueq);
 printf(" v : (y)-> %s \n\n", veq);
 stop();
 clrscrn();
 m = simpson_dxdy(f,u,v,nx,ay,by,ny);
 printf(" Compute the mass m.\n");
 printf(" (by (v(y)\n");
 printf(" m = int( int( f(x,y) dx dy = %.1f\n", m);
 printf(" (ay (u(y)\n\n");
 Mx = simpson_dxdy(h,u,v,nx,ay,by,ny);
 printf(" Compute the moment Mx.\n");
 printf(" (by (v(y)\n");
 printf(" Mx = int( int( y f(x,y) dx dy = %.1f\n", Mx);
 printf(" (ay (u(y)\n\n");
 My = simpson_dxdy(g,u,v,nx,ay,by,ny);
 printf(" Compute the moment My.\n");
 printf(" (by (v(y)\n");
 printf(" My = int( int( x f(x,y) dx dy = %.1f\n", My);
 printf(" (ay (u(y)\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.
 x = y**2, x = 4, 
 and if f(x,y), the area mass density at the point P(x,y), 
 is directly proportional to the distance from the y-axis to P
 f : (x,y)-> x 
 These give : 
 by : +2.0 
 ay : -2.0 
 u : (y)-> y**2 
 v : (y)-> 4 
 Press return to continue. 
Exemple de sortie écran :
 Compute the mass m.
 (by (v(y)
 m = int( int( f(x,y) dx dy = 25.6
 (ay (u(y)
 Compute the moment Mx.
 (by (v(y)
 Mx = int( int( y f(x,y) dx dy = 0.0
 (ay (u(y)
 Compute the moment My.
 (by (v(y)
 My = int( int( x f(x,y) dx dy = 73.1
 (ay (u(y)
 The center of mass is (X,Y)
 X = My/m = 2.86 Y = Mx/m = 0.00
 Press return to continue.

Mathc initiation/c57cc
Installer et compiler ces fichiers dans votre répertoire de travail.
/* save as c17c.c */
int main(void)
double a = -PI/4.;
double b = PI/4.;
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 = sec(x), x = -Pi/4, x = Pi/4, y = 1/2, \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(" 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 = sec(x), x = -Pi/4, x = Pi/4, y = 1/2, 
 and f(x,y) (the area mass density at (x,y)) 
 f : (x,y)-> 4 
 These give : 
 These give : 
 b : +0.8 
 a : -0.8 
 u : (x)-> 1./2. 
 v : (x)-> 1/cos(x) 
 Press return to continue. 
Exemple de sortie écran :
 Compute the mass m.
 (b (v(x)
 m = int( int( f(x,y) dy dx = 3.9
 (a (u(x)
 Compute the moment Mx.
 (b (v(x)
 Mx = int( int( y f(x,y) dy dx = 3.2
 (a (u(x)
 Compute the moment My.
 (b (v(x)
 My = int( int( x f(x,y) dy dx = 0.0
 (a (u(x)
 The center of mass is (X,Y)
 X = My/m = 0.00 Y = Mx/m = 0.82
 Press return to continue.

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

Mathc initiation/c58a2
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/c58a3
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/c58a4
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.