bonjour svp j'ai un pb j'ecris ce code en langage C, mais les résultats sont toujours fausses je ss pas pourquoi.
voila le code:
Code:/* [ programme de range kuta d'ordre 4 pour l'equation diff : y'(t)=-y+t+1 y(0)=1 t £ [0,1] */ #include<stdio.h> #include<math.h> #include<stdlib.h> #define h 0.1 int main(){ double y[11], ye[11], t[11], er[11],K1[11],K2[11],K3[11],K4[11],K[11]; y[0]=1; t[0]=0; int N=10, n; //solutiion exacte for(n=0;n<N;n++) { t[n+1]=t[n]+h; ye[n+1]=exp(-t[n+1])+t[n+1]; } //solution approchée par EULER for(n=0;n<2;n++){ t[n+1]=t[n]+h; K1[n+1]=h*(-y[n]+1+t[n]); K2[n+1]=h*(t[n]+(h/2)+1-y[n]-K1[n+1]/2); K3[n+1]=h*(t[n]+(h/2)+1-y[n]-K2[n+1]/2); K4[n+1]=h*(t[n]+h+1-y[n]-K3[n+1]); K[n+1]=(1/6)*(K1[n+1]+2*K2[n+1]+2*K3[n+1]+K4[n+1]); ( c'est là ou il ya le pb il donne toujour 0 comme calcul !!) y[n+1]=y[n]+K[n+1]; er[n+1]=fabs(y[n+1]-ye[n+1])/fabs(ye[n+1]); printf("t[%d]= %.1f\t",n+1,t[n+1]); printf("ye[%.1f]=%lf\t",t[n+1],ye[n+1]); printf("y[%d]= %lf \t",n+1,y[n+1]); printf("er[%d]= %lf\n",n+1,er[n+1]); } system("pause"); return 0; }
-----