(*Wehavethefollowingperiodicfunction*)
In[]:=
f[x_]=Which[-1<x<0,0,0<x<1,x^2]
Out[]=
Which[-1<x<0,0,0<x<1,
2
x
]
In[]:=
Plot[f[x],{x,-1,1}]
Out[]=
-1.0
-0.5
0.5
1.0
0.2
0.4
0.6
0.8
1.0
In[]:=
L=2;(*period*)
In[]:=
a[n_]:=(2/L)*Integrate[f[x]*Cos[2n*Pi*x/L],{x,-L/2,L/2}]
In[]:=
a[0]:=(1/L)*Integrate[f[x],{x,-L/2,L/2}]
In[]:=
b[n_]:=(2/L)*Integrate[f[x]*Sin[2n*Pi*x/L],{x,-L/2,L/2}]​​
In[]:=
F[x_,Nmax_]:=a[0]+Sum[a[n]*Cos[2n*Pi*x/L]+b[n]*Sin[2n*Pi*x/L],{n,1,Nmax}]​​
In[]:=
p[Nmax_,a_]:=Plot[Evaluate[F[x,Nmax]],{x,-a,a},PlotRange->All,PlotPoints->200]​​
​
In[]:=
f[x_]=If[x>0,x^2,0];
In[]:=
a[n]
Out[]=
2nπCos[nπ]+(-2+
2
n
2
π
)Sin[nπ]
3
n
3
π
In[]:=
a[0]​​
Out[]=
1
6
In[]:=
b[n]​​
Out[]=
-2+(2-
2
n
2
π
)Cos[nπ]+2nπSin[nπ]
3
n
3
π
In[]:=
Simplify[%,n∈Integers]​​
Out[]=
-
2-2
n
(-1)
+
n
(-1)
2
n
2
π
3
n
3
π
(*Withthefollowing4partialsumplots*)
In[]:=
p[5,1]
Out[]=
-1.0
-0.5
0.5
1.0
0.2
0.4
0.6
0.8
In[]:=
p[10,1]
Out[]=
-1.0
-0.5
0.5
1.0
0.2
0.4
0.6
0.8
In[]:=
p[15,1]
Out[]=
-1.0
-0.5
0.5
1.0
0.2
0.4
0.6
0.8
1.0
In[]:=
p[20,1]
Out[]=
-1.0
-0.5
0.5
1.0
0.2
0.4
0.6
0.8
1.0
(*WecalculatetheMSE(meansquareerrorforN=7,14,20)*)
In[]:=
d=Integrate[Abs[f[x]-F[x,7]]^2,{x,-L/2,L/2}];​​Sqrt[d]//N
Out[]=
0.116172
In[]:=
q=Integrate[Abs[f[x]-F[x,14]]^2,{x,-L/2,L/2}];​​Sqrt[q]//N
Out[]=
0.083573
In[]:=
w=Integrate[Abs[f[x]-F[x,20]]^2,{x,-L/2,L/2}];​​Sqrt[w]//N
Out[]=
0.0702951
(*WeconfirmtheBesselinequality*)
In[]:=
Integrate[f[x]^2,{x,-L,L}]
Out[]=
32
5
In[]:=
Information@Integers
Out[]=
Symbol
Integers represents the domain of integers, as in x∈Integers.
Documentation
Local »
|
Web »
Attributes
{Protected,ReadProtected}
Full Name
System`Integers
​
In[]:=
(a[0]^2)/2+Sum[(a[n]^2+b[n]^2),{n,1,Infinity}]<=Integrate[f[x]^2,{x,-L,L}]
Out[]=
True