class
pro{
public static void main(String args[]){
int s,n;
double x,y;
double h;
double a[]=
new double
[101];
double b[]=new double[101];
for (n=1;n<101;n++){
y=0;
for (s=-100;s<101;s++){
x=s*h;
y=y+f(x)*Math.cos(n*x)*h;
}
a[n]=y/Math.PI;
}
for (n=1;n<101;n++){
y=0;
for (s=-100;s<101;s++){
x=s*h;
y=y+f(x)*Math.sin(n*x)*h;
}
b[n]=y/Math.PI;
}
y=0;
for (s=-100;s<101;s++){
x=s*h;
y=y+f(x)*h;
}
a[0]=0.5*y/Math.PI;
for (s=-100;s<101;s++){
x=s*h;
System.out.
print(f(x));
System.out.print(",");
System.out.println(fou(a,b,x));
}
}
public static double fou(double[] a,double[] b,double x){
double f1;
int n;
f1=a[0];
for (n=1;n<101;n++){
f1=f1+a[n]*Math.cos(n*x)+b[n]*Math.sin(n*x);
}
return f1;
}
public static double f(double x){
double x1,f2;
x1=x;
if (x1<0)x1=-x1;
f2=x1;
return f2;
}
}
最終更新:2010年10月22日 23:04