Mathc initiation/c33a3
Installer ce fichier dans votre répertoire de travail.
x_dydx.h |
---|
/* ---------------------------------- */
/* save as x_dydx.h */
/* ---------------------------------- */
double int_dy(
double (*P_f)(double x, double y),
double (*P_ay)(double x),
double (*P_by)(double x),
int ny,
double x
)
{
int i = 0;
double m = 0.;
double M = 0.;
for(i = 0; i <= ny; i++)
{
if(i ==0 || i== ny){m = 1.;}
else {m = 2.;}
M += m * (*P_f)( x, ((*P_ay)( x)) + i*(((*P_by)( x))-((*P_ay)( x)))/ny);
}
return( ((((*P_by)( x))-((*P_ay)( x)))*M) / (2*ny) );
}
/* ---------------------------------- */
double trapezoid_dydx(
double (*P_f)(double x, double y),
double (*P_ay)(double x),
double (*P_by)(double x),
int ny,
double ax,
double bx,
int nx
)
{
int i = 0;
double m = 0.;
double M = 0.;
for(i = 0; i <= nx; i++)
{
if(i ==0 || i== nx){m = 1.;}
else {m = 2.;}
M += m * int_dy((*P_f), (*P_ay),(*P_by),ny, (ax+i*(bx-ax)/nx));
}
return( ((bx-ax)*M) / (2*nx) );
}
/* ---------------------------------- */
/* ---------------------------------- */
Les fonctions pour calculer les intégrales de la forme dydx.