목차
없음
본문내용
.0)*w[9]+(1.97-1.9)/(2.0-1.9)*w[10];
printf("w(1.97) = %f y(1.97) = %f error = %f\n",y3,y(1.97),y3-y(1.97));
}
float f(float w, float t){
return 2*w/t+t*t*exp(t);
}
float y(float t){
return t*t*(exp(t)-exp(1));
}
Result
/*
This program is Euler's Method for exercise 5.2.10
y' = exp(-0.06*pi*t)*(1.202377*cos(2*t-pi)-0.735745*sin(2*t-pi))
for 0<=t<=10 with y(0)=0 and h=0.1
*/
#include
#include
float f(float w, float t);
float pi = 3.141593;
main(){
int i, N = 100;
float t, h=0.1;
float w[101];
w[0] = 0;
for(i=0 ; i
t = h*i +1;
w[i+1] = w[i]+ h*f(w[i],t);
}
for(i=0 ; i<=N ; i++){
t =h*i;
printf("w(%1.1f) = %f ",t,w[i]);
if((i%4)==3)printf("\n");
}
getchar();
}
float f(float w, float t){
return exp(-0.06*pi*t)*(1.202377*cos(2*t-pi)-0.735745*sin(2*t-pi));
}
Result
printf("w(1.97) = %f y(1.97) = %f error = %f\n",y3,y(1.97),y3-y(1.97));
}
float f(float w, float t){
return 2*w/t+t*t*exp(t);
}
float y(float t){
return t*t*(exp(t)-exp(1));
}
Result
/*
This program is Euler's Method for exercise 5.2.10
y' = exp(-0.06*pi*t)*(1.202377*cos(2*t-pi)-0.735745*sin(2*t-pi))
for 0<=t<=10 with y(0)=0 and h=0.1
*/
#include
#include
float f(float w, float t);
float pi = 3.141593;
main(){
int i, N = 100;
float t, h=0.1;
float w[101];
w[0] = 0;
for(i=0 ; i
w[i+1] = w[i]+ h*f(w[i],t);
}
for(i=0 ; i<=N ; i++){
t =h*i;
printf("w(%1.1f) = %f ",t,w[i]);
if((i%4)==3)printf("\n");
}
getchar();
}
float f(float w, float t){
return exp(-0.06*pi*t)*(1.202377*cos(2*t-pi)-0.735745*sin(2*t-pi));
}
Result
소개글