Chapter 3

Off[General::munfl]

Section 3.2

3.2.1

(a)

The function here is f(x) = 1, -L ≤x≤L.  Since this function is a periodic continuous function its Fourier series equals 1 on entire real line. With L=2 this is shown below.

aa=-2;bb=2;ff[x_]=1;fft[x_]:=ff[x-(Ceiling[((x-aa)/(bb-aa))]-1)(bb-aa)]

Module[{pic1,pic2},pic1=Plot[{ff[x]},{x,-2,2},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{-4,7},{-2,2}}];pic2=Plot[{fft[x]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},PlotRange->{{-4,7},{-2,2}}];Show[pic1,pic2]]

(b)

The function here is f(x) = (x^2), -L ≤x≤L.  Since the periodic extension of this function is continuous, its Fourier series equals the periodic extension. With L=2 this is shown below.

aa=-2;bb=2;ff[x_]=x^2;fft[x_]:=ff[x-(Ceiling[((x-aa)/(bb-aa))]-1)(bb-aa)]

Module[{pic1,pic2},pic1=Plot[{ff[x]},{x,-2,2},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{-4,7},{-2,5}}];pic2=Plot[{fft[x]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10,14,4],PlotRange->{{-4,7},{-2,5}},AspectRatio->Automatic];pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{#,3}],Point[{#,-1}],Point[{#,1}]}&/@Range[-10,13,4]},{PointSize[0.014],White,{Point[{#,3}],Point[{#,-1}]}&/@Range[-10,13,4]}
}];Show[pic1,pic2]]

(c)

The function here is f(x) = 1+x, -L ≤x≤L. The periodic extension of this function has jumps. The Fourier series takes average values exactly in the middle of each jump. With L=2 this is shown below.

aa=-2;bb=2;ff[x_]=1+x;fft[x_]:=ff[x-(Ceiling[((x-aa)/(bb-aa))]-1)(bb-aa)]

Module[{pic1,pic2,pic2a},pic1=Plot[{ff[x]},{x,-2,2},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{-4,7},{-4,4}}];pic2=Plot[{fft[x]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10,14,4],PlotRange->{{-4,7},{-4,4}},AspectRatio->Automatic];pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{#,3}],Point[{#,-1}],Point[{#,1}]}&/@Range[-10,13,4]},{PointSize[0.014],White,{Point[{#,3}],Point[{#,-1}]}&/@Range[-10,13,4]}
}];Show[pic1,pic2,pic2a]]

(d)

The function here is f(x) = (e^x), -L ≤x≤L. The periodic extension of this function has jumps. The Fourier series takes average values exactly in the middle of each jump. With L=2 this is shown below.

aa=-2;bb=2;ff[x_]=Exp[x];fft[x_]:=ff[x-(Ceiling[((x-aa)/(bb-aa))]-1)(bb-aa)]

N[Exp[2]]

Module[{pic1,pic2,pic2a},pic1=Plot[{ff[x]},{x,aa,bb},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{-4,11},{0,8}}];pic2=Plot[{fft[x]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10,14,1],PlotRange->{{-4,11},{0,8}},AspectRatio->Automatic];pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{#,Exp[2]}],Point[{#,Exp[-2]}],Point[{#,(1/2)(Exp[2]+Exp[-2])}]}&/@Range[-10,13,4]},{PointSize[0.014],White,{Point[{#,Exp[2]}],Point[{#,Exp[-2]}]}&/@Range[-10,13,4]}
}];Show[pic1,pic2,pic2a]]

(e)

The function here is f(x) = x, -L ≤x≤0, f(x) = 2x, 0 ≤x≤L. The periodic extension of this function has jumps. The Fourier series takes average values exactly in the middle of each jump. With L=1 this is shown below.

aa=-1;bb=1;ff[x_]=If[x<0,x,2 x];fft[x_]:=ff[x-(Ceiling[((x-aa)/(bb-aa))]-1)(bb-aa)]

Module[{pic1,pic2,pic2a},pic1=Plot[{ff[x]},{x,-1,1},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{-4,7},{-2,3}}];pic2=Plot[{fft[x]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-11,14,2],PlotRange->{{-4,7},{-2,3}},AspectRatio->Automatic];pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{#,1/2}],Point[{#,-1}],Point[{#,2}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{#,2}],Point[{#,-1}]}&/@Range[-11,13,2]}
}];Show[pic1,pic2,pic2a]]

(f)

The function here is f(x) = 0, -L ≤x<0,f(x) = 1+x, 0 ≤x≤L. The periodic extension of this function has jumps. The Fourier series takes average values exactly in the middle of each jump. With L=1 this is shown below.

aa=-1;bb=1;ff[x_]=UnitStep[x](1+x);fft[x_]:=ff[x-(Ceiling[((x-aa)/(bb-aa))]-1)(bb-aa)]

Module[{pic1,pic2,pic2a},pic1=Plot[{ff[x]},{x,aa,bb},PlotStyle->{{Thickness[0.01],Blue}},Exclusions->{0},PlotRange->{{-4,7},{-1,3}}];pic2=Plot[{fft[x]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10,14,1],PlotRange->{{-4,7},{-1,3}},AspectRatio->Automatic];pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{#,0}],Point[{#,1}],Point[{#,1/2}]}&/@Range[-10,13,2],{Point[{#,0}],Point[{#,2}],Point[{#,1}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{#,0}],Point[{#,1}]}&/@Range[-10,13,2],{Point[{#,0}],Point[{#,2}]}&/@Range[-11,13,2]}
}];Show[pic1,pic2,pic2a]]

(g)

The function here is f(x) = x, -L ≤x<L/2,f(x) =0, L/2 ≤x≤L. The periodic extension of this function has jumps. The Fourier series takes average values exactly in the middle of each jump. With L=2 this is shown below.

aa=-2;bb=2;ff[x_]=UnitStep[1-x](x);fft[x_]:=ff[x-(Ceiling[((x-aa)/(bb-aa))]-1)(bb-aa)]

Module[{pic1,pic2,pic2a},pic1=Plot[{ff[x]},{x,aa,bb},PlotStyle->{{Thickness[0.01],Blue}},Exclusions->{1},PlotRange->{{-4,11},{-3,2}}];pic2=Plot[{fft[x]},{x,-5,14},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Join[Range[-10,14,4],Range[-11,14,4]],PlotRange->{{-4,11},{-3,2}},AspectRatio->Automatic];pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{#,0}],Point[{#,1}],Point[{#,1/2}]}&/@Range[-11,13,4],{Point[{#,0}],Point[{#,-2}],Point[{#,-1}]}&/@Range[-10,13,4]},{PointSize[0.014],White,{Point[{#,0}],Point[{#,1}]}&/@Range[-11,13,4],{Point[{#,0}],Point[{#,-2}]}&/@Range[-10,13,4]}
}];Show[pic1,pic2,pic2a]]

3.2.2

(a)

The function here is f(x) = x, -L ≤x≤L. The periodic extension of this function has jumps. The Fourier series takes the average values exactly in the middle of each jump. With L=2 this is shown below.

aa=-2;bb=2;ff[x_]=x;fft[x_]:=ff[x-(Ceiling[((x-aa)/(bb-aa))]-1)(bb-aa)]

Since this function is odd we have (Subscript[a, n])=0 for all n=0,1,.... The coefficients with the sine functions are given below

Clear[cb,lL,nn];

nn=20;
cb[n_,lL_]=FullSimplify[(1/lL)Integrate[x Sin[((n Pi)/lL)x],{x,-lL,lL}],n∈Integers]

Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{ff[x]},{x,-2,2},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{-4,11},{-3,3}}];pic2=Plot[{fft[x]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10,14,4],PlotRange->{{-4,11},{-3,3}},AspectRatio->Automatic];pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{#,-2}],Point[{#,2}],Point[{#,0}]}&/@Range[-10,13,4]},{PointSize[0.014],White,{Point[{#,-2}],Point[{#,2}]}&/@Range[-10,13,4]}
}];pic3=Plot[Evaluate[{Sum[cb[n,2]Sin[((n Pi)/2)x],{n,1,nn}]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotRange->{{-4,11},{-3,3}}];Show[pic1,pic2,pic2a,pic3]]

(b)

The function here is f(x) = Exp[-x], -L ≤x≤L. The periodic extension of this function has jumps. The Fourier series takes the average values exactly in the middle of each jump. With L=1 this is shown below.

aa=-1;bb=1;ff[x_]=Exp[-x];fft[x_]:=ff[x-(Ceiling[((x-aa)/(bb-aa))]-1)(bb-aa)]

The Fourier coefficients are given below

Clear[ca0,ca,cb,lL,nn];

nn=20;
ca0[lL_]=FullSimplify[(1/(2lL))Integrate[Exp[-x],{x,-lL,lL}]]
ca[n_,lL_]=FullSimplify[(1/lL)Integrate[Exp[-x]Cos[((n Pi)/lL)x],{x,-lL,lL}],n∈Integers]
cb[n_,lL_]=FullSimplify[(1/lL)Integrate[Exp[-x] Sin[((n Pi)/lL)x],{x,-lL,lL}],n∈Integers]

Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{ff[x]},{x,-1,1},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{-4,7},{0,3}}];pic2=Plot[{fft[x]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-11,14,2],PlotRange->{{-4,7},{0,3}},AspectRatio->Automatic];pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{#,Exp[-1]}],Point[{#,Exp[1]}],Point[{#,(1/2)(Exp[-1]+Exp[1])}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{#,Exp[-1]}],Point[{#,Exp[1]}]}&/@Range[-11,13,2]}
}];pic3=Plot[Evaluate[{ca0[1]+Sum[ca[n,1]Cos[((n Pi)/1)x]+cb[n,1]Sin[((n Pi)/1)x],{n,1,nn}]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200,PlotRange->{{-4,7},{0,3}}];Show[pic1,pic2,pic2a,pic3]]

(d)

The function here is f(x) = x UnitStep[x], -L ≤x≤L. The periodic extension of this function has jumps. The Fourier series takes the average values exactly in the middle of each jump. With L=1 this is shown below.

aa=-1;bb=1;ff[x_]=x UnitStep[x];fft[x_]:=ff[x-(Ceiling[((x-aa)/(bb-aa))]-1)(bb-aa)]

The Fourier coefficients are given below

Clear[ca0,ca,cb,lL,nn];

nn=20;
ca0[lL_]=FullSimplify[(1/(2lL))Integrate[ff[x],{x,-lL,lL}],And[lL∈Reals,lL>0]]
ca[n_,lL_]=FullSimplify[(1/lL)Integrate[ff[x]Cos[((n Pi)/lL)x],{x,-lL,lL}],And[lL∈Reals,lL>0,n∈Integers]]
cb[n_,lL_]=FullSimplify[(1/lL)Integrate[ff[x] Sin[((n Pi)/lL)x],{x,-lL,lL}],And[lL∈Reals,lL>0,n∈Integers]]

Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{ff[x]},{x,-1,1},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{-4,7},{-1,2}}];pic2=Plot[{fft[x]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-11,14,2],PlotRange->{{-4,7},{-1,2}},AspectRatio->Automatic];pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{#,0}],Point[{#,1}],Point[{#,(1/2)}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{#,0}],Point[{#,1}]}&/@Range[-11,13,2]}
}];pic3=Plot[Evaluate[{ca0[1]+Sum[ca[n,1]Cos[((n Pi)/1)x]+cb[n,1]Sin[((n Pi)/1)x],{n,1,nn}]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200,AspectRatio->Automatic,PlotRange->{{-4,7},{-1,2}}];Show[pic1,pic2,pic2a,pic3,AspectRatio->Automatic,ImageSize->500]]

(e)

The function here is f(x) = UnitStep[L/2-Abs[x]], -L ≤x≤L. The periodic extension of this function has jumps. The Fourier series takes the average values exactly in the middle of each jump. With L=2 this is shown below.

Clear[aa,bb,ff,fft];

aa=-2;bb=2;ff[x_,lL_]= UnitStep[lL/2-Abs[x]];fft[x_,lL_]:=ff[x-(Ceiling[((x-aa)/(bb-aa))]-1)(bb-aa),lL]

The Fourier coefficients are given below

Clear[ca0,ca,cb,lL,nn];

nn=20;
ca0[lL_]=FullSimplify[(1/(2lL))Integrate[1,{x,-lL/2,lL/2}],And[lL∈Reals,lL>0]]
ca[n_,lL_]=FullSimplify[(1/lL)Integrate[1Cos[((n Pi)/lL)x],{x,-lL/2,lL/2}],And[lL∈Reals,lL>0,n∈Integers]]
cb[n_,lL_]=FullSimplify[(1/lL)Integrate[1 Sin[((n Pi)/lL)x],{x,-lL/2,lL/2}],And[lL∈Reals,lL>0,n∈Integers]]

Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{ff[x,2]},{x,-2,2},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{-4,7},{-1,2}}];pic2=Plot[{fft[x,2]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-11,14,2],PlotRange->{{-4,7},{-1,2}},AspectRatio->Automatic];
pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{#,0}],Point[{#,1}],Point[{#,(1/2)}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{#,0}],Point[{#,1}]}&/@Range[-11,13,2]}
}];pic3=Plot[Evaluate[{ca0[2]+Sum[ca[n,2]Cos[((n Pi)/2)x]+cb[n,2]Sin[((n Pi)/2)x],{n,1,nn}]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200,AspectRatio->Automatic,PlotRange->{{-4,7},{-1,2}}];Show[pic1,pic2,pic2a,pic3,AspectRatio->Automatic,ImageSize->500]]

The Fourier series is 1/2 + (∑_(n=1)^∞)((2 Sin[((n π)/2)])/(n π))Cos[((n π)/L)x].

(f)

The function here is f(x) = UnitStep[L/2-Abs[x]], -L ≤x≤L. The periodic extension of this function has jumps. The Fourier series takes the average values exactly in the middle of each jump. With L=2 this is shown below.

Clear[aa,bb,ff,fft];

aa=-2;bb=2;ff[x_]= UnitStep[x];fft[x_,lL_]:=ff[x-(Ceiling[((x+lL)/(2 lL))]-1)(2 lL)]

The Fourier coefficients are given below

Clear[ca0,ca,cb,lL,nn];

nn=20;
ca0[lL_]=FullSimplify[(1/(2lL))Integrate[1,{x,0,lL}],And[lL∈Reals,lL>0]]
ca[n_,lL_]=FullSimplify[(1/lL)Integrate[1Cos[((n Pi)/lL)x],{x,0,lL}],And[lL∈Reals,lL>0,n∈Integers]]
cb[n_,lL_]=FullSimplify[(1/lL)Integrate[1 Sin[((n Pi)/lL)x],{x,0,lL}],And[lL∈Reals,lL>0,n∈Integers]]

Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{ff[x]},{x,-2,2},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{-4,7},{-1,2}}];pic2=Plot[{fft[x,2]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-11,14,2],PlotRange->{{-4,7},{-1,2}},AspectRatio->Automatic];
pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{#,0}],Point[{#,1}],Point[{#,(1/2)}]}&/@Range[-10,13,2]},{PointSize[0.014],White,{Point[{#,0}],Point[{#,1}]}&/@Range[-10,13,2]}
}];pic3=Plot[Evaluate[{ca0[2]+Sum[ca[n,2]Cos[((n Pi)/2)x]+cb[n,2]Sin[((n Pi)/2)x],{n,1,nn}]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200,AspectRatio->Automatic,PlotRange->{{-4,7},{-1,2}}];Show[pic1,pic2,pic2a,pic3,AspectRatio->Automatic,ImageSize->500]]

(g)

The function here is f(x) = 1+ UnitStep[x], -L ≤x≤L. The periodic extension of this function has jumps. The Fourier series takes the average values exactly in the middle of each jump. With L=2 this is shown below.

Clear[aa,bb,ff,fft];

aa=-2;bb=2;ff[x_]=1 +UnitStep[x];fft[x_,lL_]:=ff[x-(Ceiling[((x+lL)/(2 lL))]-1)(2 lL)]

The Fourier coefficients are given below

Clear[ca0,ca,cb,lL,nn];

nn=20;
ca0[lL_]=FullSimplify[(1/(2lL))Integrate[ff[x],{x,-lL,lL}],And[lL∈Reals,lL>0]]
ca[n_,lL_]=FullSimplify[(1/lL)Integrate[ff[x]Cos[((n Pi)/lL)x],{x,-lL,lL}],And[lL∈Reals,lL>0,n∈Integers]]
cb[n_,lL_]=FullSimplify[(1/lL)Integrate[ff[x] Sin[((n Pi)/lL)x],{x,-lL,lL}],And[lL∈Reals,lL>0,n∈Integers]]

Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{ff[x]},{x,-2,2},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{-4,7},{-1,3}}];pic2=Plot[{fft[x,2]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-11,14,2],PlotRange->{{-4,7},{-1,3}},AspectRatio->Automatic];
pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{#,1+0}],Point[{#,1+1}],Point[{#,1+(1/2)}]}&/@Range[-10,13,2]},{PointSize[0.014],White,{Point[{#,1+0}],Point[{#,1+1}]}&/@Range[-10,13,2]}
}];pic3=Plot[Evaluate[{ca0[2]+Sum[ca[n,2]Cos[((n Pi)/2)x]+cb[n,2]Sin[((n Pi)/2)x],{n,1,nn}]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200,AspectRatio->Automatic,PlotRange->{{-4,7},{-1,3}}];Show[pic1,pic2,pic2a,pic3,AspectRatio->Automatic,ImageSize->500]]

3.2.3

Given two pws functions f  and  g  both defined on (-L,L] and their Fourier series

(Subscript[a, 0])+(∑_(n=1)^∞)((Subscript[a, n])Cos[((n π)/L)x]+(Subscript[b, n])Sin[((n π)/L)x])

where

(Subscript[a, 0])=(1/(2 L))(∫_(-L)^L)f(x)dx, (Subscript[a, n])=(1/L)(∫_(-L)^L)f(x)Cos[((n π)/L)x]dx, (Subscript[b, n])=(1/L)(∫_(-L)^L)f(x)Sin[((n π)/L)x]dx

Similarly

(Subscript[c, 0])+(∑_(n=1)^∞)((Subscript[c, n])Cos[((n π)/L)x]+(Subscript[d, n])Sin[((n π)/L)x])

where

(Subscript[c, 0])=(1/(2 L))(∫_(-L)^L)g(x)dx, (Subscript[c, n])=(1/L)(∫_(-L)^L)g(x)Cos[((n π)/L)x]dx, (Subscript[d, n])=(1/L)(∫_(-L)^L)g(x)Sin[((n π)/L)x]dx

Let  α, β  be real numbers. Now we consider the function   α f+β g. This function is pwc on (-L,L]. Let

(Subscript[p, 0])+(∑_(n=1)^∞)((Subscript[p, n])Cos[((n π)/L)x]+(Subscript[q, n])Sin[((n π)/L)x])

be the Fourier series of   α f+β g.

(Subscript[p, 0])=(1/(2 L))(∫_(-L)^L)(α f(x)+β g(x))dx, 

(Subscript[p, n])=(1/L)(∫_(-L)^L)(α f(x)+β g(x))Cos[((n π)/L)x]dx, 

(Subscript[q, n])=(1/L)(∫_(-L)^L)(α f(x)+β g(x))Sin[((n π)/L)x]dx

From the linearity property of integrals we have

(Subscript[p, 0])=α (Subscript[a, 0])+β (Subscript[c, 0]), 

(Subscript[p, n])=α (Subscript[a, n])+β (Subscript[c, n]), 

(Subscript[q, n])=α (Subscript[b, n])+β (Subscript[d, n]).

Therefore

(Subscript[p, 0])+(∑_(n=1)^∞)((Subscript[p, n])Cos[((n π)/L)x]+(Subscript[q, n])Sin[((n π)/L)x]) = (α (Subscript[a, 0])+β (Subscript[c, 0]))+(∑_(n=1)^∞)((α (Subscript[a, n])+β (Subscript[c, n]))Cos[((n π)/L)x]+(α (Subscript[b, n])+β (Subscript[d, n]))Sin[((n π)/L)x])=
 (α (Subscript[a, 0])+(∑_(n=1)^∞)(α (Subscript[a, n])Cos[((n π)/L)x]+α (Subscript[b, n])Sin[((n π)/L)x]))+(β (Subscript[c, 0])+(∑_(n=1)^∞)(β (Subscript[c, n])Cos[((n π)/L)x]+β (Subscript[d, n])Sin[((n π)/L)x]))=
α((Subscript[a, 0])+(∑_(n=1)^∞)((Subscript[a, n])Cos[((n π)/L)x]+(Subscript[b, n])Sin[((n π)/L)x]))+β((Subscript[c, 0])+(∑_(n=1)^∞)((Subscript[c, n])Cos[((n π)/L)x]+(Subscript[d, n])Sin[((n π)/L)x]))

Thus we proved: 

(the Fourier series of   α f+β g) = α (the Fourier series of f) + β (the Fourier series of g)

3.2.4

Let f be a pws function on [-L,L].  Then one sided limits f(-L+)  and  f(L-) exist.  If  f(-L+) = f(L-) then the periodic extension of f is continuous at both -L  and  L.  Therefore the sum of the Fourier series of f at L  and -L equals to the value f(L) = f(-L).  If  f(-L+)  ≠ f(L-) then the periodic extension of f  has a jump at both  -L  and  L.  The left-hand limit of the periodic extension of f at -L is  f(L-).  The right-hand limit of the periodic extension of f at -L is  f(-L+).  Therefore the sum of the Fourier series of f at -L  is  (1/2)(f(L) + f(-L)).  The left-hand limit of the periodic extension of f at L is  f(L-).  The right-hand limit of the periodic extension of f at L is  f(-L+).  Therefore the sum of the Fourier series of f at L  is also   (1/2)(f(L) + f(-L)).

Section 3.3

General definitions:

Clear[vf,fft,ffo,ffe,lL,x]; 

fft[vf_,x_,lL_]:=vf[x-(Ceiling[((x+lL)/(2 lL))]-1)(2 lL)];
ffo[vf_,x_]:=If[x<0,-vf[-x],vf[x]];
ffe[vf_,x_]:=If[x<0,vf[-x],vf[x]];

3.3.1

(a)

The function here is f(x) = 1, -L ≤x≤L.

Clear[ff];

ff[x_]=1;    lL=2;

The Fourier series

Show[Plot[{ff[x]},{x,-lL,lL},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{-7,11},{-1.5,1.5}}],Plot[{fft[ff[#]&,x,lL]},{x,-20,20},PlotStyle->{{Thickness[0.005],Green}},PlotRange->{{-7,11},{-1.5,1.5}}]]

The Fourier sine series

Show[Plot[{ff[x],ffo[ff[#]&,x]},{x,-lL,lL},PlotStyle->{{Thickness[0.01],Blue},{Thickness[0.007],Cyan}},Exclusions->{0},PlotRange->{{-7,11},{-1.5,1.5}}],Plot[{fft[ffo[ff[#]&,#]&,x,lL]},{x,-20,20},PlotStyle->{{Thickness[0.001],Green}},Exclusions->Range[-10,12,2],PlotRange->{{-7,11},{-1.5,1.5}}]]

The Fourier cosine series

Show[Plot[{ff[x],ffe[ff[#]&,x]},{x,-lL,lL},PlotStyle->{{Thickness[0.01],Blue},{Thickness[0.007],Cyan}},Exclusions->{0},PlotRange->{{-7,11},{-1.5,1.5}}],Plot[{fft[ffe[ff[#]&,#]&,x,lL]},{x,-20,20},PlotStyle->{{Thickness[0.001],Green}},Exclusions->Range[-10,12,2],PlotRange->{{-7,11},{-1.5,1.5}}]]

(b)

The function here is f(x) = 1+x, -L ≤x≤L.

Clear[ff];

ff[x_]=1+x;  xmin=-7;xmax=11;ymin=-4;ymax=4; lL=2;

The Fourier series

Show[Plot[{ff[x]},{x,-lL,lL},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{xmin,xmax},{ymin,ymax}}],Plot[{fft[ff[#]&,x,lL]},{x,-20,20},PlotStyle->{{Thickness[0.003],Green}},PlotRange->{{xmin,xmax},{ymin,ymax}}]]

The Fourier sine series

Show[Plot[{ff[x],ffo[ff[#]&,x]},{x,-lL,lL},PlotStyle->{{Thickness[0.01],Blue},{Thickness[0.007],Cyan}},Exclusions->{0},PlotRange->{{xmin,xmax},{ymin,ymax}}],Plot[{fft[ffo[ff[#]&,#]&,x,lL]},{x,-20,20},PlotStyle->{{Thickness[0.003],Green}},Exclusions->Range[-10,12,2],PlotRange->{{xmin,xmax},{ymin,ymax}}]]

The Fourier cosine series

Show[Plot[{ff[x],ffe[ff[#]&,x]},{x,-lL,lL},PlotStyle->{{Thickness[0.01],Blue},{Thickness[0.007],Cyan}},Exclusions->{0},PlotRange->{{xmin,xmax},{ymin,ymax}}],Plot[{fft[ffe[ff[#]&,#]&,x,lL]},{x,-20,20},PlotStyle->{{Thickness[0.003],Green}},Exclusions->Range[-10,12,2],PlotRange->{{xmin,xmax},{ymin,ymax}}]]

(c)

The function here is f(x) = x +UnitStep[x], -L ≤x≤L.

Clear[ff];

ff[x_]=x+UnitStep[x];  xmin=-7;xmax=11;ymin=-4;ymax=4; lL=2;

The Fourier series

Show[Plot[{ff[x]},{x,-lL,lL},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{xmin,xmax},{ymin,ymax}}],Plot[{fft[ff[#]&,x,lL]},{x,-20,20},PlotStyle->{{Thickness[0.003],Green}},PlotRange->{{xmin,xmax},{ymin,ymax}}]]

The Fourier sine series

Show[Plot[{ff[x],ffo[ff[#]&,x]},{x,-lL,lL},PlotStyle->{{Thickness[0.01],Blue},{Thickness[0.007],Cyan}},Exclusions->{0},PlotRange->{{xmin,xmax},{ymin,ymax}}],Plot[{fft[ffo[ff[#]&,#]&,x,lL]},{x,-20,20},PlotStyle->{{Thickness[0.003],Green}},Exclusions->Range[-10,12,2],PlotRange->{{xmin,xmax},{ymin,ymax}}]]

The Fourier cosine series

Show[Plot[{ff[x],ffe[ff[#]&,x]},{x,-lL,lL},PlotStyle->{{Thickness[0.01],Blue},{Thickness[0.007],Cyan}},Exclusions->{0},PlotRange->{{xmin,xmax},{ymin,ymax}}],Plot[{fft[ffe[ff[#]&,#]&,x,lL]},{x,-20,20},PlotStyle->{{Thickness[0.003],Green}},Exclusions->Range[-10,12,2],PlotRange->{{xmin,xmax},{ymin,ymax}}]]

(d)

The function here is f(x) = Exp[x], -L ≤x≤L.

Clear[ff];

ff[x_]=Exp[x];  xmin=-4;xmax=7;ymin=-3;ymax=3; lL=1;

The Fourier series

Show[Plot[{ff[x]},{x,-lL,lL},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{xmin,xmax},{ymin,ymax}}],Plot[{fft[ff[#]&,x,lL]},{x,-20,20},PlotStyle->{{Thickness[0.003],Green}},PlotRange->{{xmin,xmax},{ymin,ymax}}]]

The Fourier sine series

Show[Plot[{ff[x],ffo[ff[#]&,x]},{x,-lL,lL},PlotStyle->{{Thickness[0.01],Blue},{Thickness[0.007],Cyan}},Exclusions->{0},PlotRange->{{xmin,xmax},{ymin,ymax}}],Plot[{fft[ffo[ff[#]&,#]&,x,lL]},{x,-20,20},PlotStyle->{{Thickness[0.003],Green}},Exclusions->Range[-11,12,1],PlotRange->{{xmin,xmax},{ymin,ymax}}]]

The Fourier cosine series

Show[Plot[{ff[x],ffe[ff[#]&,x]},{x,-lL,lL},PlotStyle->{{Thickness[0.01],Blue},{Thickness[0.007],Cyan}},Exclusions->{0},PlotRange->{{xmin,xmax},{ymin,ymax}}],Plot[{fft[ffe[ff[#]&,#]&,x,lL]},{x,-20,20},PlotStyle->{{Thickness[0.003],Green}},Exclusions->Range[-10,12,2],PlotRange->{{xmin,xmax},{ymin,ymax}}]]

(e)

The function here is f(x) =2 (1-UnitStep[x])+ UnitStep[x] Exp[-x], -L ≤x≤L.

Clear[ff];

ff[x_]=2(1-UnitStep[x])+UnitStep[x]Exp[x];  xmin=-4;xmax=7;ymin=-3;ymax=3; lL=1;

The Fourier series

Show[Plot[{ff[x]},{x,-lL,lL},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->{{xmin,xmax},{ymin,ymax}}],Plot[{fft[ff[#]&,x,lL]},{x,-20,20},PlotStyle->{{Thickness[0.003],Green}},PlotRange->{{xmin,xmax},{ymin,ymax}}]]

The Fourier sine series

Show[Plot[{ff[x],ffo[ff[#]&,x]},{x,-lL,lL},PlotStyle->{{Thickness[0.01],Blue},{Thickness[0.007],Cyan}},Exclusions->{0},PlotRange->{{xmin,xmax},{ymin,ymax}}],Plot[{fft[ffo[ff[#]&,#]&,x,lL]},{x,-20,20},PlotStyle->{{Thickness[0.003],Green}},Exclusions->Range[-10,12,1],PlotRange->{{xmin,xmax},{ymin,ymax}}]]

The Fourier cosine series

Show[Plot[{ff[x],ffe[ff[#]&,x]},{x,-lL,lL},PlotStyle->{{Thickness[0.01],Blue},{Thickness[0.007],Cyan}},Exclusions->{0},PlotRange->{{xmin,xmax},{ymin,ymax}}],Plot[{fft[ffe[ff[#]&,#]&,x,lL]},{x,-20,20},PlotStyle->{{Thickness[0.003],Green}},Exclusions->Range[-10,12,2],PlotRange->{{xmin,xmax},{ymin,ymax}}]]

3.3.2

(a)

The function here is f(x) =Cos[(π/L)x], 0≤x≤L.

Clear[ff,x,lL];

ff[x_,lL_]=Cos[(Pi/lL)x];

cb[n_]=FullSimplify[(2/lL)Integrate[ff[x,lL]Sin[((n Pi)/lL)x],{x,0,lL}],And[lL>0,n∈Integers,n>0]]

There is a problem at n=1

cb[1]=FullSimplify[(2/lL)Integrate[ff[x,lL]Sin[((1 Pi)/lL)x],{x,0,lL}],And[lL>0]]

cb[n_]=FullSimplify[(2/lL)Integrate[ff[x,lL]Sin[((n Pi)/lL)x],{x,0,lL}],And[lL>0,n∈Integers,n>0]]

cb[1]

The Fourier sine series

xmin=-4;xmax=7;ymin=-1.5;ymax=1.5; lL=2; nn=10;


Show[Plot[{ff[x,lL]},{x,0,lL},PlotStyle->{{Thickness[0.01],Blue}},
Exclusions->{0},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{ffo[ff[#,lL]&,x]},{x,-lL,lL},
PlotStyle->{{Thickness[0.008],Cyan}},
Exclusions->{0},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{fft[ffo[ff[#,lL]&,#]&,x,lL]},{x,-20,20},
PlotStyle->{{Thickness[0.003],Red}},
Exclusions->Range[-10,12,1],PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[Evaluate[{ Sum[cb[n] Sin[((n Pi)/lL)x],{n,1,nn}]}],{x,-20,20},
PlotStyle->{{Thickness[0.003],Black}},PlotRange->{{xmin,xmax},{ymin,ymax}}]
]

(b)

The function here is f(x) =(-2 UnitStep[L/6-x]+3UnitStep[L/2-x])UnitStep[L/2-x], 0≤x≤L.

Clear[ff,x,lL];

ff[x_,lL_]=(-2UnitStep[lL/6-x]+3UnitStep[lL/2-x])UnitStep[lL/2-x];

Plot[ff[x,5],{x,0,6}]

Clear[cb];

cb[n_]=FullSimplify[(2/lL)(Integrate[Sin[((n Pi)/lL)x],{x,0,lL/6}]+Integrate[3Sin[((n Pi)/lL)x],{x,lL/6,lL/2}]),And[lL>0,n∈Integers,n>0]]

The Fourier sine series

xmin=-7;xmax=11;ymin=-3.5;ymax=3.5; lL=3; nn=20;


Show[Plot[{ff[x,lL]},{x,0,lL},PlotStyle->{{Thickness[0.01],Blue}},
Exclusions->{0,lL/6,lL/2},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{ffo[ff[#,lL]&,x]},{x,-lL,lL},
PlotStyle->{{Thickness[0.008],Cyan}},
Exclusions->{0,lL/6,lL/2,-lL/6,-lL/2},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{fft[ffo[ff[#,lL]&,#]&,x,lL]},{x,-20,20},
PlotStyle->{{Thickness[0.003],Red}},
Exclusions->Range[-10,12,1/2],PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[Evaluate[{ Sum[cb[n] Sin[((n Pi)/lL)x],{n,1,nn}]}],{x,-20,20},PlotPoints->200,
PlotStyle->{{Thickness[0.003],Black}},PlotRange->{{xmin,xmax},{ymin,ymax}}]
]

(c)

The function here is f(x) =x UnitStep[x-L/2] , 0≤x≤L.

Clear[ff,x,lL];

ff[x_,lL_]=x UnitStep[x-lL/2];

Plot[ff[x,5],{x,0,6}]

Clear[cb];

cb[n_]=FullSimplify[(2/lL)(Integrate[x Sin[((n Pi)/lL)x],{x,lL/2,lL}]),And[lL>0,n∈Integers,n>0]]

The Fourier sine series

xmin=-7;xmax=11;ymin=-3.5;ymax=3.5; lL=3; nn=20;


Show[Plot[{ff[x,lL]},{x,0,lL},PlotStyle->{{Thickness[0.01],Blue}},
Exclusions->{0,lL/6,lL/2},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{ffo[ff[#,lL]&,x]},{x,-lL,lL},
PlotStyle->{{Thickness[0.008],Cyan}},
Exclusions->{0,lL/6,lL/2,-lL/6,-lL/2},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{fft[ffo[ff[#,lL]&,#]&,x,lL]},{x,-20,20},
PlotStyle->{{Thickness[0.003],Red}},
Exclusions->Range[-10,12,1/2],PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[Evaluate[{ Sum[cb[n] Sin[((n Pi)/lL)x],{n,1,nn}]}],{x,-20,20},PlotPoints->200,
PlotStyle->{{Thickness[0.003],Black}},PlotRange->{{xmin,xmax},{ymin,ymax}}]
]

(d)

The function here is f(x) =x UnitStep[x-L/2] , 0≤x≤L.

Clear[ff,x,lL];

ff[x_,lL_]=UnitStep[lL/2-x];

Plot[ff[x,5],{x,0,6}]

Clear[cb];

cb[n_]=FullSimplify[(2/lL)(Integrate[Sin[((n Pi)/lL)x],{x,0,lL/2}]),And[lL>0,n∈Integers,n>0]]

The Fourier sine series

xmin=-7;xmax=11;ymin=-1.5;ymax=1.5; lL=3; nn=20;


Show[Plot[{ff[x,lL]},{x,0,lL},PlotStyle->{{Thickness[0.01],Blue}},
Exclusions->{0,lL/6,lL/2},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{ffo[ff[#,lL]&,x]},{x,-lL,lL},
PlotStyle->{{Thickness[0.008],Cyan}},
Exclusions->{0,lL/6,lL/2,-lL/6,-lL/2},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{fft[ffo[ff[#,lL]&,#]&,x,lL]},{x,-20,20},
PlotStyle->{{Thickness[0.003],Red}},
Exclusions->Range[-10,12,1/2],PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[Evaluate[{ Sum[cb[n] Sin[((n Pi)/lL)x],{n,1,nn}]}],{x,-20,20},PlotPoints->200,
PlotStyle->{{Thickness[0.003],Black}},PlotRange->{{xmin,xmax},{ymin,ymax}}]
]

3.3.3

(a) Done in 3.3.2 (a)

(b) Done in 3.3.2 (d)

(c)

The function here is f(x) =x, 0≤x≤L.

Clear[ff,x,lL];

ff[x_,lL_]=x;

cb[n_]=FullSimplify[(2/lL)Integrate[ff[x,lL]Sin[((n Pi)/lL)x],{x,0,lL}],And[lL>0,n∈Integers,n>0]]

The Fourier sine series

xmin=-7;xmax=11;ymin=-2.5;ymax=2.5; lL=2; nn=10;


Show[Plot[{ff[x,lL]},{x,0,lL},PlotStyle->{{Thickness[0.01],Blue}},
Exclusions->{0},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{ffo[ff[#,lL]&,x]},{x,-lL,lL},
PlotStyle->{{Thickness[0.008],Cyan}},
Exclusions->{0},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{fft[ffo[ff[#,lL]&,#]&,x,lL]},{x,-20,20},
PlotStyle->{{Thickness[0.003],Red}},
Exclusions->Range[-10,12,1],PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[Evaluate[{ Sum[cb[n] Sin[((n Pi)/lL)x],{n,1,nn}]}],{x,-20,20},
PlotStyle->{{Thickness[0.003],Black}},PlotRange->{{xmin,xmax},{ymin,ymax}}]
]

3.3.4

The function here is f(x) =Sin[(π/L)x], 0≤x≤L.

Clear[ff,x,lL];

ff[x_,lL_]=Sin[(Pi/lL)x];

Clear[ca0]; 

ca0=FullSimplify[(1/lL)Integrate[ff[x,lL],{x,0,lL}],And[lL>0]]

Clear[ca];

ca[n_]=FullSimplify[(2/lL)Integrate[ff[x,lL]Cos[((n Pi)/lL)x],{x,0,lL}],And[lL>0,n∈Integers,n>0]]

There is a problem with n=1.

ca[1]=FullSimplify[(2/lL)Integrate[ff[x,lL]Cos[(Pi/lL)x],{x,0,lL}],And[lL>0]]

The Fourier cosine series

xmin=-3;xmax=7;ymin=-.5;ymax=1.5; lL=2; nn=8;


Show[Plot[{ff[x,lL]},{x,0,lL},PlotStyle->{{Thickness[0.01],Blue}},
Exclusions->{},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{ffe[ff[#,lL]&,x]},{x,-lL,lL},
PlotStyle->{{Thickness[0.008],Cyan}},
Exclusions->{},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{fft[ffe[ff[#,lL]&,#]&,x,lL]},{x,-20,20},
PlotStyle->{{Thickness[0.003],Red}},
PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[Evaluate[{ ca0+Sum[ca[n] Cos[((n Pi)/lL)x],{n,1,nn}]}],{x,-20,20},
PlotStyle->{{Thickness[0.003],Black}},PlotRange->{{xmin,xmax},{ymin,ymax}}]
]

3.3.5

(a)

The function here is f(x) =(x^2), 0≤x≤L.

Clear[ff,x,lL];

ff[x_,lL_]=(x^2);

Plot[ff[x,5],{x,0,6}]

Clear[ca0,ca,lL];

ca0[lL_]= FullSimplify[(1/lL)(Integrate[ff[x,lL],{x,0,lL}]),And[lL>0]]


ca[n_,lL_]=FullSimplify[(2/lL)(Integrate[ff[x,lL] Cos[((n Pi)/lL)x],{x,0,lL}]),And[lL>0,n∈Integers,n>0]]

The Fourier cosine series

xmin=-5;xmax=7;ymin=-.5;ymax=4.5; lL=2; nn=7;


Show[Plot[{ff[x,lL]},{x,0,lL},PlotStyle->{{Thickness[0.01],Blue}},
Exclusions->None,PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{ffe[ff[#,lL]&,x]},{x,-lL,lL},
PlotStyle->{{Thickness[0.008],Cyan}},
Exclusions->{0,lL/6,lL/2,-lL/6,-lL/2},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{fft[ffe[ff[#,lL]&,#]&,x,lL]},{x,-20,20},
PlotStyle->{{Thickness[0.003],Red}},
Exclusions->None,PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[Evaluate[{ ca0[lL]+Sum[ca[n,lL] Cos[((n Pi)/lL)x],{n,1,nn}]}],{x,-20,20},PlotPoints->200,
PlotStyle->{{Thickness[0.003],Black}},PlotRange->{{xmin,xmax},{ymin,ymax}}]
]

(b)

The function here is f(x) =(-2 UnitStep[L/6-x]+3UnitStep[L/2-x])UnitStep[L/2-x], 0≤x≤L.

Clear[ff,x,lL];

ff[x_,lL_]=(-2UnitStep[lL/6-x]+3UnitStep[lL/2-x])UnitStep[lL/2-x];

Plot[ff[x,5],{x,0,6}]

Clear[ca0,ca];

ca0= FullSimplify[(1/lL)(Integrate[1,{x,0,lL/6}]+Integrate[3,{x,lL/6,lL/2}]),And[lL>0]]


ca[n_]=FullSimplify[(2/lL)(Integrate[Cos[((n Pi)/lL)x],{x,0,lL/6}]+Integrate[3Cos[((n Pi)/lL)x],{x,lL/6,lL/2}]),And[lL>0,n∈Integers,n>0]]

The Fourier cosine series

xmin=-7;xmax=11;ymin=-.5;ymax=3.5; lL=3; nn=20;


Show[Plot[{ff[x,lL]},{x,0,lL},PlotStyle->{{Thickness[0.01],Blue}},
Exclusions->{0,lL/6,lL/2},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{ffe[ff[#,lL]&,x]},{x,-lL,lL},
PlotStyle->{{Thickness[0.008],Cyan}},
Exclusions->{0,lL/6,lL/2,-lL/6,-lL/2},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{fft[ffe[ff[#,lL]&,#]&,x,lL]},{x,-20,20},
PlotStyle->{{Thickness[0.003],Red}},
Exclusions->Range[-10,12,1/2],PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[Evaluate[{ ca0+Sum[ca[n] Cos[((n Pi)/lL)x],{n,1,nn}]}],{x,-20,20},PlotPoints->200,
PlotStyle->{{Thickness[0.003],Black}},PlotRange->{{xmin,xmax},{ymin,ymax}}]
]

(c)

The function here is f(x) =x UnitStep[x-L/2], 0≤x≤L.

Clear[ff,x,lL];

ff[x_,lL_]=x UnitStep[x-lL/2];

Plot[ff[x,5],{x,0,6}]

Clear[ca0,ca];

ca0= FullSimplify[(1/lL)(Integrate[x,{x,lL/2,lL}]),And[lL>0]]


ca[n_]=FullSimplify[(2/lL)(Integrate[x Cos[((n Pi)/lL)x],{x,lL/2,lL}]),And[lL>0,n∈Integers,n>0]]

The Fourier cosine series

xmin=-7;xmax=11;ymin=-.5;ymax=3.5; lL=3; nn=10;


Show[Plot[{ff[x,lL]},{x,0,lL},PlotStyle->{{Thickness[0.01],Blue}},
Exclusions->{0,lL/6,lL/2},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{ffe[ff[#,lL]&,x]},{x,-lL,lL},
PlotStyle->{{Thickness[0.008],Cyan}},
Exclusions->{0,lL/6,lL/2,-lL/6,-lL/2},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{fft[ffe[ff[#,lL]&,#]&,x,lL]},{x,-20,20},
PlotStyle->{{Thickness[0.003],Red}},
Exclusions->Range[-10,12,1/2],PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[Evaluate[{ ca0+Sum[ca[n] Cos[((n Pi)/lL)x],{n,1,nn}]}],{x,-20,20},PlotPoints->200,
PlotStyle->{{Thickness[0.003],Black}},PlotRange->{{xmin,xmax},{ymin,ymax}}]
]

3.3.6

(a)

The function here is f(x) =x, 0≤x≤L.

Clear[ff,x,lL];

ff[x_,lL_]=x;

Plot[ff[x,5],{x,0,6}]

Clear[ca0,ca,lL,n];

ca0[lL_]= FullSimplify[(1/lL)(Integrate[ff[x,lL],{x,0,lL}]),And[lL>0]]


ca[n_,lL_]=FullSimplify[(2/lL)(Integrate[ff[x,lL] Cos[((n Pi)/lL)x],{x,0,lL}]),And[lL>0,n∈Integers,n>0]]

The Fourier cosine series

xmin=-5;xmax=7;ymin=-.5;ymax=2.5; lL=2; nn=7;


Show[Plot[{ff[x,lL]},{x,0,lL},PlotStyle->{{Thickness[0.01],Blue}},
Exclusions->None,PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{ffe[ff[#,lL]&,x]},{x,-lL,lL},
PlotStyle->{{Thickness[0.008],Cyan}},
Exclusions->None,PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{fft[ffe[ff[#,lL]&,#]&,x,lL]},{x,-20,20},
PlotStyle->{{Thickness[0.003],Red}},
Exclusions->None,PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[Evaluate[{ ca0[lL]+Sum[ca[n,lL] Cos[((n Pi)/lL)x],{n,1,nn}]}],{x,-20,20},PlotPoints->200,
PlotStyle->{{Thickness[0.003],Black}},PlotRange->{{xmin,xmax},{ymin,ymax}}]
]

(b)

The function here is f(x) =UnitStep[x-L/2], 0≤x≤L.

Clear[ff,x,lL];

ff[x_,lL_]=UnitStep[x-lL/2];

Plot[ff[x,5],{x,0,6}]

Clear[ca0,ca,lL];

ca0[lL_]= FullSimplify[(1/lL)(Integrate[1,{x,lL/2,lL}]),And[lL>0]]


ca[n_,lL_]=FullSimplify[(2/lL)(Integrate[Cos[((n Pi)/lL)x],{x,lL/2,lL}]),And[lL>0,n∈Integers,n>0]]

The Fourier cosine series

xmin=-4;xmax=7;ymin=-.5;ymax=1.5; lL=2; nn=10;


Show[Plot[{ff[x,lL]},{x,0,lL},PlotStyle->{{Thickness[0.01],Blue}},
Exclusions->{lL/2},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{ffe[ff[#,lL]&,x]},{x,-lL,lL},
PlotStyle->{{Thickness[0.008],Cyan}},
Exclusions->Range[-11,12,2],PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{fft[ffe[ff[#,lL]&,#]&,x,lL]},{x,-20,20},
PlotStyle->{{Thickness[0.003],Red}},
Exclusions->Range[-10,12,1/2],PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[Evaluate[{ ca0[lL]+Sum[ca[n,lL] Cos[((n Pi)/lL)x],{n,1,nn}]}],{x,-20,20},PlotPoints->200,
PlotStyle->{{Thickness[0.003],Black}},PlotRange->{{xmin,xmax},{ymin,ymax}}]
]

(c)

The function here is f(x) =UnitStep[L/2-x], 0≤x≤L.

Clear[ff,x,lL];

ff[x_,lL_]=UnitStep[lL/2-x];

Plot[ff[x,5],{x,0,6}]

Clear[ca0,ca,lL];

ca0[lL_]= FullSimplify[(1/lL)(Integrate[1,{x,0,lL/2}]),And[lL>0]]


ca[n_,lL_]=FullSimplify[(2/lL)(Integrate[Cos[((n Pi)/lL)x],{x,0,lL/2}]),And[lL>0,n∈Integers,n>0]]

The Fourier cosine series

xmin=-4;xmax=7;ymin=-.5;ymax=1.5; lL=2; nn=10;


Show[Plot[{ff[x,lL]},{x,0,lL},PlotStyle->{{Thickness[0.01],Blue}},
Exclusions->{lL/2},PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{ffe[ff[#,lL]&,x]},{x,-lL,lL},
PlotStyle->{{Thickness[0.008],Cyan}},
Exclusions->Range[-11,12,2],PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{fft[ffe[ff[#,lL]&,#]&,x,lL]},{x,-20,20},
PlotStyle->{{Thickness[0.003],Red}},
Exclusions->Range[-10,12,1/2],PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[Evaluate[{ ca0[lL]+Sum[ca[n,lL] Cos[((n Pi)/lL)x],{n,1,nn}]}],{x,-20,20},PlotPoints->200,
PlotStyle->{{Thickness[0.003],Black}},PlotRange->{{xmin,xmax},{ymin,ymax}}]
]

Notice that adding the functions in (b) and (c) one gets 1. So we did not even need to calculate the second series; we could have subbtracted the series in (b) from 1.

3.3.7

Plot[{Cosh[x],Sinh[x],Exp[x]+0.07,Exp[x]-0.07,Exp[x]},{x,-2.6,2.6},PlotStyle->{{Thickness[0.005],Blue},{Thickness[0.005],Red},{Thickness[0.005],Blue},{Thickness[0.005],Red},{Thickness[0.004],White}},PlotRange->{-6,6}]

The above plot is my attempt to illustrate the formula

Exp[x] = Cosh[x]+Sinh[x]

which follows from the definition of the hyperbolic functions Cosh and Sinh.

3.3.8

(a)

Here is a Mathematica formula for the even part (its funny name is ffep) of a function (with a funny name)  vf   and  a Mathematica formula for the even extension (its funny name is ffee) of a function (with a funny name) vf.

Clear[vf,ffep,ffee,lL,x]; 

ffep[vf_,x_]:=(1/2)(vf[x]+vf[-x]);

ffee[vf_,x_]:=If[x<0,vf[-x],vf[x]];

The formula for the even part takes into accunt values of  vf  at positive and at negative numbers  x.  The formula for the even extension takes into accunt only the values of  vf  at positive  x by reflecting the graph of  vf accross the y-axes.  Here is an example: the original function is blue, its even part in cyan and the even extension in magenta.

Clear[ff,x]; 

ff[x_]=Exp[x];

Plot[{ff[x],ffep[ff[#]&,x],ffee[ff[#]&,x]},{x,-2.6,2.6},PlotStyle->{{Thickness[0.01],Blue},{Thickness[0.005],Cyan},{Thickness[0.005],Magenta}},PlotRange->{-.2,6}]

Clear[ff,x]; 

ff[x_]=(x^2)Exp[-x]UnitStep[x];

Plot[{ff[x],ffep[ff[#]&,x],ffee[ff[#]&,x]},{x,-4.6,4.6},PlotStyle->{{Thickness[0.01],Blue},{Thickness[0.005],Cyan},{Thickness[0.005],Magenta}},PlotRange->{-.2,.7}]

(b)

Here is a Mathematica formula for the odd part (its funny name is ffop) of a function (with a funny name)  vf   and  a Mathematica formula for the odd extension (its funny name is ffoe) of a function (with a funny name) vf.

Clear[vf,ffop,ffoe,lL,x]; 

ffop[vf_,x_]:=(1/2)(vf[x]-vf[-x]);

ffoe[vf_,x_]:=If[x<0,-vf[-x],vf[x]];

Clear[ff,x]; 

ff[x_]=Exp[x];

Plot[{ff[x],ffop[ff[#]&,x],ffoe[ff[#]&,x]},{x,-2.6,2.6},PlotStyle->{{Thickness[0.01],Blue},{Thickness[0.005],Cyan},{Thickness[0.005],Magenta}},Exclusions-> {0},PlotRange->{-6,6}]

Clear[ff,x]; 

ff[x_]=(x^2)Exp[-x]UnitStep[x];

Plot[{ff[x],ffop[ff[#]&,x],ffoe[ff[#]&,x]},{x,-4.6,4.6},PlotStyle->{{Thickness[0.01],Blue},{Thickness[0.005],Cyan},{Thickness[0.005],Magenta}},PlotRange->{-.7,.7}]

(c)

Clear[ff,x]; 

ff[x_]=(x^2)UnitStep[x]+x UnitStep[-x];

In the plot below the odd part blue, the even part red, the sum green and the original function black.

Plot[{
ffop[ff[#]&,x],ffep[ff[#]&,x],
ffop[ff[#]&,x]+ffep[ff[#]&,x],
ff[x]},{x,-3.,3.},PlotStyle->{{Thickness[0.005],Blue},{Thickness[0.005],Red},{Thickness[0.01],Green},{Thickness[0.004],Black}},PlotRange->{-3,3},AspectRatio->Automatic]

In the plot below the odd extension blue, the even extension red, the sum green and the original function black.

Plot[{
ffoe[ff[#]&,x],ffee[ff[#]&,x],
ffoe[ff[#]&,x]+ffee[ff[#]&,x],
ff[x]},{x,-3.,3.},PlotStyle->{{Thickness[0.005],Blue},{Thickness[0.005],Red},{Thickness[0.01],Green},{Thickness[0.004],Black}},PlotRange->{-3,3},AspectRatio->Automatic]

3.3.9

The sum of the Fourier sine series and the Fourier cosine series of f (defined on (0,L)) is the function which equals 0 on (-L,0)  equals 2f on  (0,L) and then periodically extended.  Here are examples.

Example 1

The function here is f(x) =(x^2), 0≤x≤L.

Clear[ff,x,lL];

ff[x_,lL_]=(x^2);

Clear[ca0,ca,lL];

ca0[lL_]= FullSimplify[(1/lL)(Integrate[ff[x,lL],{x,0,lL}]),And[lL>0]]


ca[n_,lL_]=FullSimplify[(2/lL)(Integrate[ff[x,lL] Cos[((n Pi)/lL)x],{x,0,lL}]),And[lL>0,n∈Integers,n>0]]

cb[n_,lL_]=FullSimplify[(2/lL)(Integrate[ff[x,lL] Sin[((n Pi)/lL)x],{x,0,lL}]),And[lL>0,n∈Integers,n>0]]

The function is in blue. The approximation of Fourier cosine series is in magenta, the approximation of the Fourier  sine series is in cyan,  the sum of the previous two series is in black, the periodic extension of the function  2 UnitStep[x]f(x)  is yellow.

xmin=-3;xmax=5;ymin=-1.5;ymax=2.5; lL=1; nn=20;

Show[Plot[{ff[x,lL]},{x,0,lL},PlotStyle->{{Thickness[0.01],Blue}},
Exclusions->None,PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{fft[2(UnitStep[#]ff[#,lL])&,x,lL]},{x,-20,20},
PlotStyle->{{Thickness[0.005],Yellow}},
Exclusions->Range[-11,12,2],PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[Evaluate[{ ca0[lL]+Sum[ca[n,lL] Cos[((n Pi)/lL)x],{n,1,nn}],Sum[cb[n,lL] Sin[((n Pi)/lL)x],{n,1,nn}],ca0[lL]+Sum[ca[n,lL] Cos[((n Pi)/lL)x],{n,1,nn}]+Sum[cb[n,lL] Sin[((n Pi)/lL)x],{n,1,nn}]}],{x,-20,20},PlotPoints->200,
PlotStyle->{{Thickness[0.003],Magenta},{Thickness[0.003],Cyan},{Thickness[0.003],Black}},PlotRange->{{xmin,xmax},{ymin,ymax}}]
]

Example 2

The function here is f(x) =(x^2), 0≤x≤L.

Clear[ff,x,lL];

ff[x_,lL_]=(4/lL)x (lL-x);

ff[lL/2,lL]

Clear[ca0,ca,lL];

ca0[lL_]= FullSimplify[(1/lL)(Integrate[ff[x,lL],{x,0,lL}]),And[lL>0]]


ca[n_,lL_]=FullSimplify[(2/lL)(Integrate[ff[x,lL] Cos[((n Pi)/lL)x],{x,0,lL}]),And[lL>0,n∈Integers,n>0]]

cb[n_,lL_]=FullSimplify[(2/lL)(Integrate[ff[x,lL] Sin[((n Pi)/lL)x],{x,0,lL}]),And[lL>0,n∈Integers,n>0]]

The function is in blue. The approximation of Fourier cosine series is in magenta, the approximation of the Fourier  sine series is in cyan,  the sum of the previous two series is in black, the periodic extension of the function  2 UnitStep[x]f(x)  is yellow.

xmin=-3;xmax=4;ymin=-1.2;ymax=2.2; lL=1; nn=7;

Show[Plot[{ff[x,lL]},{x,0,lL},PlotStyle->{{Thickness[0.01],Blue}},
Exclusions->None,PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[{fft[2(UnitStep[#]ff[#,lL])&,x,lL]},{x,-20,20},
PlotStyle->{{Thickness[0.01],Yellow}},
Exclusions->Range[-11,12,2],PlotRange->{{xmin,xmax},{ymin,ymax}}],
Plot[Evaluate[{ ca0[lL]+Sum[ca[n,lL] Cos[((n Pi)/lL)x],{n,1,nn}],Sum[cb[n,lL] Sin[((n Pi)/lL)x],{n,1,nn}],ca0[lL]+Sum[ca[n,lL] Cos[((n Pi)/lL)x],{n,1,nn}]+Sum[cb[n,lL] Sin[((n Pi)/lL)x],{n,1,nn}]}],{x,-20,20},PlotPoints->200,
PlotStyle->{{Thickness[0.003],Magenta},{Thickness[0.003],Cyan},{Thickness[0.003],Black}},PlotRange->{{xmin,xmax},{ymin,ymax}}]
]

3.3.10

Clear[ff,x]; 

ff[x_]=Exp[-x]UnitStep[x]+(x^(2 ))UnitStep[-x];

Plot[{ff[x],ffep[ff[#]&,x],ffop[ff[#]&,x]},{x,-2,2},PlotStyle->{{Thickness[0.01],Blue},{Thickness[0.005],Cyan},{Thickness[0.005],Magenta}},PlotRange->{-4,4}]

3.3.12

(a)

Here we make linear combination of the functions of the form  Sin[((2 k π)/L)x], where k is an integer. It is sufficient to prove that all these functions is odd around  L/2. The easiest way to show this is to tranlaste this function to the left by  L/2 and show that such a function is odd. The translation is

Clear[tf,x,k,lL]; tf[x_]=Sin[((2 k Pi)/lL)(x+(lL/2))]

Here is the mathematica proof:

FullSimplify[tf[x]+tf[-x],k∈Integers]

Or we could have done this directly with the given function

FullSimplify[Sin[((2 k Pi)/lL)(x+(lL/2))]+Sin[((2 k Pi)/lL)(-x+(lL/2))],k∈Integers]

To do this by hand we just use periodicity of the sine function.

(b)

To prove this statement it is useful to shift all functions by L/2  to the left.  By assumption the function  f(x+L/2)  is odd.  Below Mathematica shows that the functions  Sin[(((2 k+1) π)/lL)(x+(lL/2))]  are even.

FullSimplify[Sin[(((2 k+1) Pi)/lL)(x+(lL/2))]-Sin[(((2 k+1) Pi)/lL)(-x+(lL/2))],k∈Integers]

Consequently the products  f(x+L/2) Sin[(((2 k+1) π)/L)(x+(L/2))]  are odd. Therefore the integrals over  (-L/2,L/2) are  0.  Therefore the integrals of   s  f(x) Sin[(((2 k+1) π)/L)x]  over (0,L)  are  0.

3.3.13

This is similar to 3.3.12 (b).

3.3.14

(a)

This is similar to 3.3.12(b).

(b)

Assume that the function f is even around x=L/2. This symmetry implies (prove this) that the Fourier cosine series of the function f defined on (0,L) is identical to the Fourier cosine series of the function f defined on (0,L/2).

3.3.15

This is similar to 3.3.12 (b).

3.3.17

Integrate[(1/(1+(x^2))),{x,0,1}]

Sum[(((-1))^n)(x^(2 n)),{n,0,Infinity}]

FullSimplify[Integrate[(((-1))^n)(x^(2 n)),{x,0,1}],n>-1/2]

Sum[((((-1))^n)/(1+2 n)),{n,0,Infinity}]

3.3.18

(a)

Assume that f(x) is a continuous and piecewise smooth function on the interval [-L,L] and f(-L)=f(L). Then the Fourier series of f converges uniformly to f on the interval  [-L,L].

(b)

Assume that f(x) is a continuous and piecewise smooth function on the interval [0,L] and f(0)=f(L)=0. Then the Fourier sine series of f converges uniformly to f on the interval  [0,L].

(c)

Assume that f(x) is a continuous and piecewise smooth function on the interval [0,L].  Then the Fourier cosine series of f converges uniformly to f on the interval  [0,L].

Section 3.4

3.4.10

Solution

We look for a solution in the form

u[x,t]=(∑_(n=1)^∞)(Subscript[b, n])[t]Sin[((n π)/L)x]

This function satisfies the boundary condition.

Using the initial condition yields the information about

(Subscript[b, n])[0]=(2/L)(∫_0^L)f[ξ]Sin[((n π)/L)ξ]dξ

Now we only have to make sure that the given function satisfies the PDE

(∑_(n=1)^∞)(Subscript[b, n])'[t]Sin[((n π)/L)x]=-k(∑_(n=1)^∞)(Subscript[b, n])[t](((((n π)/L)))^2)Sin[((n π)/L)x]+g[x]

(∑_(n=1)^∞)((Subscript[b, n])'[t]+k (((((n π)/L)))^2)(Subscript[b, n])[t])Sin[((n π)/L)x]=g[x]

Using the orthogonality of sines we get

(L/2)((Subscript[b, n])'[t]+k (((((n π)/L)))^2)(Subscript[b, n])[t])=(∫_0^L)g[ξ]Sin[((n π)/L)ξ]dξ

(Subscript[b, n])'[t]+k (((((n π)/L)))^2)(Subscript[b, n])[t]=(2/L)(∫_0^L)g[ξ]Sin[((n π)/L)ξ]dξ

This is a simple linear equation for  (Subscript[b, n])[t]. It is solved by using integrating factor

Exp[k (((((n π)/L)))^2)t](Subscript[b, n])'[t]+k (((((n π)/L)))^2)Exp[k (((((n π)/L)))^2)t](Subscript[b, n])[t]=Exp[k (((((n π)/L)))^2)t](2/L)(∫_0^L)g[ξ]Sin[((n π)/L)ξ]dξ

(d/dt)(Exp[k (((((n π)/L)))^2)t](Subscript[b, n])[t])=Exp[k (((((n π)/L)))^2)t](2/L)(∫_0^L)g[ξ]Sin[((n π)/L)ξ]dξ

Exp[k (((((n π)/L)))^2)t](Subscript[b, n])[t]=(1/(k (((((n π)/L)))^2)))Exp[k (((((n π)/L)))^2)t](2/L)(∫_0^L)g[ξ]Sin[((n π)/L)ξ]dξ+ C[1]

(Subscript[b, n])[t]=((2 L)/(k (((n π))^2)))(∫_0^L)g[ξ]Sin[((n π)/L)ξ]dξ+ C[1]Exp[-k (((((n π)/L)))^2)t]

Now use the value at 0

(Subscript[b, n])[0]=(2/L)(∫_0^L)f[ξ]Sin[((n π)/L)ξ]dξ

(2/L)(∫_0^L)f[ξ]Sin[((n π)/L)ξ]dξ -((2 L)/(k (((n π))^2)))(∫_0^L)g[ξ]Sin[((n π)/L)ξ]dξ= C[1]

Thus

(Subscript[b, n])[t]=(1-Exp[-k (((((n π)/L)))^2)t])((2 L)/(k (((n π))^2)))(∫_0^L)g[ξ]Sin[((n π)/L)ξ]dξ+ Exp[-k (((((n π)/L)))^2)t](2/L)(∫_0^L)f[ξ]Sin[((n π)/L)ξ]dξ

Implementation 1

Given the following functions

Clear[ff,gg,lL,kk];

lL=1; 

kk=1;

ff[x_]=0; 

gg[x_]=x(1-x);

Clear[bb,n];

bb[t_,n_]=(1-Exp[-kk (((((n π)/lL)))^2)t])((2 lL)/(kk (((n π))^2)))(∫_0^lL)gg[ξ]Sin[((n π)/lL)ξ]\[DifferentialD]ξ+ Exp[-kk (((((n π)/lL)))^2)t](2/lL)(∫_0^lL)ff[ξ]Sin[((n π)/lL)ξ]\[DifferentialD]ξ

Clear[uu,nn];

nn=20;

uu[x_,t_]=(∑_(n=1)^nn)bb[t,n]Sin[((n π)/lL)x]

Plot3D[uu[x,t],{x,0,1},{t,0,1}]

Plot[{uu[x,10],gg[x]},{x,0,1}]

How can we verify this solution?  We can find the equilibrium temperature distribution and compare to the function uu[x,t]. That is done below:

DSolve[{y''[x]==-gg[x],y[0]==0,y[1]==0},y[x],x]

Plot[{uu[x,10],gg[x],(1/12) (x-2 (x^3)+(x^4))},{x,0,1},PlotStyle->{{Blue,Thickness[0.01]},{Green,Thickness[0.01]},{Red,Thickness[0.005]}}]

Implementation 2

Given the following functions

Clear[ff,gg,lL,kk];

lL=1; 

kk=1;

ff[x_]=4(x^2) (1-Exp[x-1]); 

gg[x_]=1;

Plot[ff[x],{x,0,1}]

Clear[bb,n];

bb[t_,n_]=(1-Exp[-kk (((((n π)/lL)))^2)t])((2 lL)/(kk (((n π))^2)))(∫_0^lL)gg[ξ]Sin[((n π)/lL)ξ]\[DifferentialD]ξ+ Exp[-kk (((((n π)/lL)))^2)t](2/lL)(∫_0^lL)ff[ξ]Sin[((n π)/lL)ξ]\[DifferentialD]ξ

Clear[uu,nn];

nn=20;

uu[x_,t_]=(∑_(n=1)^nn)bb[t,n]Sin[((n π)/lL)x];

Plot3D[uu[x,t],{x,0,1},{t,0,1},PlotRange->All]

Plot[{uu[x,10],gg[x]},{x,0,1}]

How can we verify this solution?  We can find the equilibrium temperature distribution and compare to the function uu[x,t]. That is done below:

eqsol[x_]=y[x]/.DSolve[{y''[x]==-gg[x],y[0]==0,y[1]==0},y[x],x][[1]]

Plot[{uu[x,10],gg[x],eqsol[x]},{x,0,1},PlotStyle->{{Blue,Thickness[0.01]},{Green,Thickness[0.01]},{Red,Thickness[0.005]}}]

Implementation 3

Given the following functions

Clear[ff,gg,lL,kk];

lL=1; 

kk=1;

ff[x_]=4(x^2) (1-Exp[x-1]); 

gg[x_]=(((Sin[2Pi x]))^2);

Clear[bb,n];

bb[t_,n_]=FullSimplify[(1-Exp[-kk (((((n π)/lL)))^2)t])((2 lL)/(kk (((n π))^2)))(∫_0^lL)gg[ξ]Sin[((n π)/lL)ξ]\[DifferentialD]ξ+ Exp[-kk (((((n π)/lL)))^2)t](2/lL)(∫_0^lL)ff[ξ]Sin[((n π)/lL)ξ]\[DifferentialD]ξ,And[n>0,n∈Integers]]

bb[t_,4]=FullSimplify[((1-Exp[-kk (((((n π)/lL)))^2)t])((2 lL)/(kk (((n π))^2)))(∫_0^lL)gg[ξ]Sin[((4 π)/lL)ξ]\[DifferentialD]ξ+ Exp[-kk (((((n π)/lL)))^2)t](2/lL)(∫_0^lL)ff[ξ]Sin[((4 π)/lL)ξ]\[DifferentialD]ξ)/.{n->4},And[n>0,n∈Integers]]

Clear[uu,nn];

nn=20;

uu[x_,t_]=(∑_(n=1)^nn)bb[t,n]Sin[((n π)/lL)x];

uu[.5,.5]

Plot3D[Evaluate[uu[x,t]],{x,0,1},{t,0,1},PlotRange->All]

Plot[{uu[x,10],gg[x]},{x,0,1}]

How can we verify this solution?  We can find the equilibrium temperature distribution and compare to the function uu[x,t]. That is done below:

eqsol[x_]=y[x]/.DSolve[{y''[x]==-gg[x],y[0]==0,y[1]==0},y[x],x][[1]]

Plot[{uu[x,10],gg[x],eqsol[x]},{x,0,1},PlotStyle->{{Blue,Thickness[0.01]},{Green,Thickness[0.01]},{Red,Thickness[0.005]}}]

3.4.12

Solution

We will consider a more general equation: 

(∂_t) u(x,t)=(∂_(x,x))u(x,t)+g(x,t)

We look for a solution in the form

u[x,t]=(Subscript[A, 0])[t]+(∑_(n=1)^∞)(Subscript[A, n])[t]Cos[((n π)/L)x]

This function satisfies the boundary condition.

Using the initial condition yields the information about

(Subscript[A, 0])[0]=(1/L)(∫_0^L)f[ξ]dξ

(Subscript[A, n])[0]=(2/L)(∫_0^L)f[ξ]Cos[((n π)/L)ξ]dξ

Now we only have to make sure that the given function satisfies the PDE

(Subscript[A, 0])'[t]+(∑_(n=1)^∞)(Subscript[A, n])'[t]Cos[((n π)/L)x]=-k(∑_(n=1)^∞)(Subscript[A, n])[t](((((n π)/L)))^2)Cos[((n π)/L)x]+g[x,t]

(Subscript[A, 0])'[t]+(∑_(n=1)^∞)((Subscript[A, n])'[t]+k (((((n π)/L)))^2)(Subscript[A, n])[t])Cos[((n π)/L)x]=g[x,t]

Using the orthogonality of cosines we get

(Subscript[A, 0])'[t]=(1/L)(∫_0^L)g[ξ,t]dξ

(Subscript[A, n])'[t]+k (((((n π)/L)))^2)(Subscript[A, n])[t]=(2/L)(∫_0^L)g[ξ,t]Cos[((n π)/L)ξ]dξ

This is a linear equation for  (Subscript[A, n])[t]. To solve it we need to know the righ-hand side.

Clear[lL,n];

(1/lL)(∫_0^lL)(Exp[-t]+Exp[-2 t]Cos[((3 Pi)/lL)ξ])\[DifferentialD]ξ

FullSimplify[(2/lL)(∫_0^lL)(Exp[-t]+Exp[-2 t]Cos[((3 Pi)/lL)ξ])Cos[((n Pi)/lL)ξ]\[DifferentialD]ξ,n∈Integers]

(2/lL)(∫_0^lL)(Exp[-t]+Exp[-2 t]Cos[((3 Pi)/lL)ξ])Cos[((3 Pi)/lL)ξ]\[DifferentialD]ξ

Expand[DSolve[{(Subscript[A, 0])'[t]==Exp[-t],(Subscript[A, 0])[0]==A0},(Subscript[A, 0])[t],t][[1]]]

Clear[kk,lL];Expand[DSolve[{(Subscript[A, 3])'[t]+kk (((((3 π)/lL)))^2)(Subscript[A, 3])[t]==Exp[-2t],(Subscript[A, 3])[0]==A3},(Subscript[A, 3])[t],t][[1]]]

Expand[((E^(-((9 kk (π^2) t)/(lL^2)))) ((-1-2 A3+(E^((-2+((9 kk (π^2))/(lL^2))) t))) (lL^2)+9 A3 kk (π^2)))/(-2 (lL^2)+9 kk (π^2))]

Simplify[((E^(-((9 kk (π^2) t)/(lL^2))+(-2+((9 kk (π^2))/(lL^2))) t)) (lL^2))/(-2 (lL^2)+9 kk (π^2))-(((E^(-((9 kk (π^2) t)/(lL^2)))) (lL^2))/(-2 (lL^2)+9 kk (π^2)))]

Simplify[-((2 A3 (E^(-((9 kk (π^2) t)/(lL^2)))) (lL^2))/(-2 (lL^2)+9 kk (π^2)))+((9 A3 (E^(-((9 kk (π^2) t)/(lL^2)))) kk (π^2))/(-2 (lL^2)+9 kk (π^2)))]+Simplify[((E^(-((9 kk (π^2) t)/(lL^2))+(-2+((9 kk (π^2))/(lL^2))) t)) (lL^2))/(-2 (lL^2)+9 kk (π^2))-(((E^(-((9 kk (π^2) t)/(lL^2)))) (lL^2))/(-2 (lL^2)+9 kk (π^2)))]

DSolve[{(Subscript[A, n])'[t]+k (((((n π)/lL)))^2)(Subscript[A, n])[t]==0,(Subscript[A, n])[0]==An},(Subscript[A, n])[t],t][[1]]

We calculated as the initial values.

(Subscript[A, 0])[0]=(1/L)(∫_0^L)f[ξ]dξ

(Subscript[A, n])[0]=(2/L)(∫_0^L)f[ξ]Cos[((n π)/L)ξ]dξ

Implementation

Clear[kk,lL,ff];

kk=1; lL = 1; ff[x_]=1;

Clear[aa]; 

aa[0]=(1/lL)(∫_0^lL)ff[ξ]\[DifferentialD]ξ

aa[n_]=FullSimplify[(2/lL)(∫_0^lL)ff[ξ]Cos[((n Pi)/lL)ξ]\[DifferentialD]ξ,n∈Integers]

AA[t_,0]=1+aa[0]-(E^(-t))

AA[t_,3]=aa[3] (E^(-((9 kk (π^2) t)/(lL^2))))-((((E^(-2 t))-(E^(-((9 kk (π^2) t)/(lL^2))))) (lL^2))/(2 (lL^2)-9 kk (π^2)))

AA[t_,n_]=aa[n] (E^(-((kk (n^2) (π^2) t)/(lL^2))))

Clear[uu,nn];

nn=20;

uu[x_,t_]=AA[t,0]+(∑_(n=1)^nn)AA[t,n]Cos[((n π)/lL)x];

Plot3D[uu[x,t],{x,0,1},{t,0,3},PlotRange->{0,2.3}]

Implementation 2

Clear[kk,lL,ff];

kk=1; lL = 1; ff[x_]=10(x^2)(((1-x))^2);

Clear[aa]; 

aa[0]=(1/lL)(∫_0^lL)ff[ξ]\[DifferentialD]ξ

aa[n_]=FullSimplify[(2/lL)(∫_0^lL)ff[ξ]Cos[((n Pi)/lL)ξ]\[DifferentialD]ξ,n∈Integers]

AA[t_,0]=1+aa[0]-(E^(-t))

aa[3]

AA[t_,3]=aa[3] (E^(-((9 kk (π^2) t)/(lL^2))))-((((E^(-2 t))-(E^(-((9 kk (π^2) t)/(lL^2))))) (lL^2))/(2 (lL^2)-9 kk (π^2)))

AA[t_,n_]=aa[n] (E^(-((kk (n^2) (π^2) t)/(lL^2))))

Clear[uu,nn];

nn=20;

uu[x_,t_]=AA[t,0]+(∑_(n=1)^nn)AA[t,n]Cos[((n π)/lL)x];

uu[.5,.5]

Plot3D[uu[x,t],{x,0,1},{t,0,1},PlotRange->{0,1.}]

3.4.13

Solution

An awkward aspect of this problem is that one boundary condition depends on time. This is the nonhomogeneous aspect of this problem. In the previous problems we delt with nonhomogeneous problems by looking for the solution in the form

u[x,t]=(∑_(n=1)^∞)(Subscript[B, n])[t]Sin[((n π)/L)x]

and trying to find (Subscript[B, n])[t]so that the nonhomogeneous equation is satisfied. The reason to choose the above form of the solution was that it automatically satisfied boundary conditions.  In this problem, in order to hava the boundary conditions satisfied we have to modify this “starting point solution”. We will look for the solution in the form

u[x,t]=((L-x)/L)A[t]+(∑_(n=1)^∞)(Subscript[B, n])[t]Sin[((n π)/L)x]

This function satisfies the boundary conditions.  Now we proceed as before and try to figure out which differential equations must be satisfied by (Subscript[B, n])[t] in order for such a function  u[x,t]  to be a solution.

Using the initial condition yields the information about

(Subscript[B, n])[0]=(2/L)(∫_0^L)(f[ξ]-((L-ξ)/L)A[0])Sin[((n π)/L)ξ]dξ

Now we make sure that the given function satisfies the PDE

((L-x)/L)A'[t]+(∑_(n=1)^∞)(Subscript[B, n])'[t]Sin[((n π)/L)x]=-k(∑_(n=1)^∞)(Subscript[B, n])[t](((((n π)/L)))^2)Sin[((n π)/L)x]

(∑_(n=1)^∞)((Subscript[B, n])'[t]+k (((((n π)/L)))^2)(Subscript[B, n])[t])Sin[((n π)/L)x]=-((L-x)/L)A'[t]

Using the orthogonality of sines we get

(L/2)((Subscript[B, n])'[t]+k (((((n π)/L)))^2)(Subscript[B, n])[t])=-A'[t](∫_0^L)((L-ξ)/L)Sin[((n π)/L)ξ]dξ

(Subscript[B, n])'[t]+k (((((n π)/L)))^2)(Subscript[B, n])[t]=-(2/L)A'[t](∫_0^L)((L-ξ)/L)Sin[((n π)/L)ξ]dξ

So, in the last equation the only red object is the function (Subscript[B, n])[t]. This is differential equation for (Subscript[B, n]) which can be solved.  Let us calculate the constant

FullSimplify[-(2/L)(∫_0^L)((L-ξ)/L)Sin[((n π)/L)ξ]\[DifferentialD]ξ,n∈Integers]

Thus we need to solve

(Subscript[B, n])'[t]+k (((((n π)/L)))^2)(Subscript[B, n])[t]=-(2/(n π))A'[t]

This is a linear equation for  (Subscript[B, n])[t]. It is solved by using integrating factor

Exp[k (((((n π)/L)))^2)t](Subscript[B, n])'[t]+k (((((n π)/L)))^2)Exp[k (((((n π)/L)))^2)t](Subscript[B, n])[t]=-(2/(n π))Exp[k (((((n π)/L)))^2)t]A'[t]

(d/dt)(Exp[k (((((n π)/L)))^2)t](Subscript[B, n])[t])=-(2/(n π))Exp[k (((((n π)/L)))^2)t]A'[t]

Exp[k (((((n π)/L)))^2)t](Subscript[B, n])[t]=(Subscript[B, n])[0]-(2/(n π))(∫_0^t)Exp[k (((((n π)/L)))^2)τ]A'[τ]dτ

(Subscript[B, n])[t]=(Subscript[B, n])[0]Exp[-k (((((n π)/L)))^2)t]-(2/(n π))Exp[-k (((((n π)/L)))^2)t](∫_0^t)Exp[k (((((n π)/L)))^2)τ]A'[τ]dτ

Notice that all objects on the right hand side are green.

Implementation 1

Given the following functions

Clear[ff,fA,lL,kk];

lL=1; 

kk=1;

ff[x_]=((lL-x)/lL); 

fA[t_]=Exp[-t];

Clear[bb,n];

bb[n_]=FullSimplify[(2/lL)(∫_0^lL)(ff[ξ]-((lL-ξ)/lL)fA[0])Sin[((n π)/lL)ξ]\[DifferentialD]ξ,And[n>0,n∈Integers]]

fA'[t]

Clear[BB];BB[t_,n_]=bb[n]Exp[-kk (((((n π)/lL)))^2)t]-(2/(n π))Exp[-kk (((((n π)/lL)))^2)t](∫_0^t)Exp[kk (((((n π)/lL)))^2)τ]fA'[τ]\[DifferentialD]τ

Clear[uu,nn];

nn=20;

uu[x_,t_]=((lL-x)/lL)fA[t]+(∑_(n=1)^nn)BB[t,n]Sin[((n π)/lL)x];

uu[x,t]

uu[.5,.5]

Plot3D[Evaluate[uu[x,t]],{x,0,1},{t,0,4.4},PlotRange->All]

Implementation 2

Given the following functions

Clear[ff,fA,lL,kk];

lL=1; 

kk=1;

ff[x_]=1-((((x/lL)))^6); 

fA[t_]=Exp[-6t];

Plot[ff[x],{x,0,1}]

Clear[bb,n];

bb[n_]=FullSimplify[(2/lL)(∫_0^lL)(ff[ξ]-((lL-ξ)/lL)fA[0])Sin[((n π)/lL)ξ]\[DifferentialD]ξ,And[n>0,n∈Integers]]

fA'[t]

Clear[BB];BB[t_,n_]=bb[n]Exp[-kk (((((n π)/lL)))^2)t]-(2/(n π))Exp[-kk (((((n π)/lL)))^2)t](∫_0^t)Exp[kk (((((n π)/lL)))^2)τ]fA'[τ]\[DifferentialD]τ

Clear[uu,nn];

nn=20;

uu[x_,t_]=((lL-x)/lL)fA[t]+(∑_(n=1)^nn)BB[t,n]Sin[((n π)/lL)x];

uu[x,t];

uu[.5,.5]

Plot3D[Evaluate[uu[x,t]],{x,0,1},{t,0,.4},PlotRange->{0,1.1}]

Manipulate[Plot[Evaluate[uu[x,t]],{x,0,1},PlotRange->{0,1.1}],{t,0,1}]