Mathc initiation/Fichiers h : x 20a3

Sommaire

Installer ce fichier dans votre répertoire de travail.

Crystal Clear mimetype source h.png x_heun.h
utilitaire
/* ---------------------------------- */
/* save as x_heun.h                  */
/* ---------------------------------- */
void p_Heun_s_Method(
double a,
double b,
double n,
double ya,
double (*P_f)(double x,double y)
)
{
double i;
double h;
double x_k;
double T;

    h = ((b-a)/n);

    printf("  k  | x_k   | y_k         \n");
    printf(" --------------------------\n");
    for(i=1,x_k=a; i<=n; i++)
        {
         T = (*P_f)(x_k,ya);
         ya = ya +(h/2.)*( T + (*P_f)(x_k+h, ya+h*T));
         x_k +=h;
         printf(" %3.f | %.3f | %.10f\n",i,x_k,ya);
        }
}
/* --------------------------------- */
/* --------------------------------- */
double Heun_s_Method(
double a,
double b,
double n,
double ya,
double (*P_f)(double x,double y)
)
{
double i;
double h;
double x_k;
double T;

    h = ((b-a)/n);

    for(i=1,x_k=a; i<=n; i++)
        {
         T = (*P_f)(x_k,ya);
         ya = ya +(h/2.)*( T + (*P_f)(x_k+h, ya+h*T));
         x_k +=h;
        }

 return(ya);
}
Déclaration des fonctions de calcul.