アットウィキロゴ

ff89

class pro{
public static void main(String args[]){
int s,n;
double th,y;
double h;
double a[]=new double[101];

h=Math.PI/100;

for (n=1;n<101;n++){
y=0;
for (s=-100;s<101;s++){
th=s*h;
y=y+f(th)*Math.cos(n*th)*h;
}
a[n]=y/Math.PI;
}


y=0;
for (s=-100;s<101;s++){
th=s*h;
y=y+f(th)*h;
}

a[0]=0.5*y/Math.PI;

for (s=-100;s<101;s++){
th=s*h;
System.out.print(f(th));
System.out.print(",");
System.out.println(fou(a,th));
}


}


public static double fou(double[] a,double th){
double f1;
int n;
f1=a[0];
for (n=1;n<101;n++){
f1=f1+a[n]*Math.cos(n*th);
}
return f1;
}


public static double f(double th){
double x1,f2;
x1=th;
if (x1<0)x1=-x1;
f2=x1+2*x1*x1+5;
return f2;
}


}
最終更新:2010年10月22日 23:46