プログラミングで近似解を求めるやつ
ほんとは過去問wikiにあげたかったけど自作じゃないし( ´ー`)y-~~おいすー
上の関数を区間[0,2π]において50分割して近似解を求めよ。
#include
#include
main(void)
{
int n;
double a,x,y,p;
FILE *cosin;
cosin=fopen("cos01.txt","w");if(cosin==NULL){
printf("Cannot open 'cos01.txt'!!\n");
return 1;
}
p=asin(1);
n=50;
a=4*p/n;
x=0;
while(x<4*p)
{
y=x-cos(x);
fprintf(cosin,"%lf,%lf \n",x,y);
x=x+a;
}
y=4*p-cos(4*p);
fprintf(cosin,"%lf,%lf \n",4*p,y);
fclose(cosin);
return 0;
}
(´ε`;)ウーン…