Fourier Series HW 1

For f[x]=x

Compute the first 4 coefficients in the Fourier Sine Series for f on the interval (0,π).

Superimpose plots of f on (0,π) and the truncated Fourier Sine Series with 4, 8, 12 terms on (-2π,2π). Explain what happens outside the interval (0,π).

Plot the relative error for your three truncated Fourier Sine Series on (-π,π).  Explain any interesting features

f[x_]:= x
Pic1= Plot[ f[x],{x,0, π},
PlotStyle->Red];
Pic2=Plot[ Sin[x],{x, -π,π}];
Show[Pic2,Pic1]

Fourier Series HW 2

For f[x]=Abs[x]

Compute the first 4 non-zero coefficients in the Fourier Series for f on the interval (-π/2,π/2).

Superimpose plots of f on (0,π) and the truncated Fourier Series with 5, 9, 13 non-zero terms on (-2π,2π). Explain what happens outside the interval (-π/2,π/2).  Explain why  some terms are automatically zero.

Plot the relative error for your three truncated Fourier Series on (-π/2,π/2).  Explain any interesting features.

Plot the derivatives of your truncated Fourier Series on (-2π, 2π).  What do you think is happening here?

Fourier Bessel Series HW 1

For f[x]=(x^2)(x-1)

Compute the first 4 coefficients in the Fourier Bessel (with n=1) Series for f on the interval (0,1).

Plot f and the truncated Fourier Bessel Series with 4, 8, and 12 non-zero terms on (-0.1,1.1). Explain what happens outside the interval (0,1).

Plot the relative error for your three truncated Fourier Bessel Series on (0,1).  Explain any interesting features.

Plot the derivatives of your truncated Fourier Bessel Series on (0, 1).  What do you think is happening here?

Design a system of Bessel functions to approximate a function that is zero at x=0 and flat at x=1 on (0,1). Explain your reasoning. Use your system to approximate 1-(((x-1))^2) and illustrate the results.

Fourier Series

Off[NIntegrate::ncvb]

k=4;
Plot[Sin[k x] Sin[k x],{x,0,π}]
Integrate[Sin[k x] Sin[k x],{x,0,π}]

Clear[a,b,kMax, k]
f[x_]:= If[x>0, Sin[x], Cos[x]]
kMax=12;

b[k_]:=b[k]=(1/π)NIntegrate[f[x] Sin[k x],{x,-π,π}]
a[k_]:=a[k]=(1/π)NIntegrate[f[x] Cos[k x],{x,-π,π}]
a[0]=(1/(2 π))NIntegrate[ f[x] ,{x,-π,π}];
F[x_]=a[0]+ Sum[ a[k] Cos[k x]+b[k] Sin[k x],{k,1,kMax}];
Plot[{f[x], F[x],F[π]},{x,-2π,1.1 π},
PlotLegends->"Expressions"]

Fourier Bessel Series

The same thing works with Bessel Functions.

Clear[R,n,k]
R[n_,k_]:=R[n,k]=BesselJ[n, N[BesselJZero[n,k]] #]&
Plot[{
R[3,1][x],
R[3,2][x],
R[3,3][x],
R[3,4][x],
R[3,5][x]
},
{x,0,1}]

Clear[a,n,k,x,f,F]
a[n_,k_]:=a[n,k]=((NIntegrate[x f[x] R[n,k][x],{x,0,1}])/(NIntegrate[x (((R[n,k][x]))^2),{x,0,1}]))
f[x_]:= (x Cos[x Sin[3 x]+ x ArcTan[x]] + (x^2))(1-x)(1-2 x)(1-3x)


kMax=8;
n=1;
F[x_]=Sum[ a[n,k] R[n,k][x],{k,1,kMax}];
Plot[{f[x], F[x]},{x,0,1},
PlotLegends->"Expressions"]