MATH661 S02 - Linear combination approximations

Posted: 09/06/23

Due: 09/13/23, 11:59PM

Tracks 1 & 2: 1. Track 2: 2.

This homework introduces the fundamentals of additive approximation techniques in vector spaces. Read and understand the concepts in L04: Linear combinations in m and 𝒞0[0,2π), in particular to the example presented in the text and in the code attached to L04: Figure 2. Additional Julia coding constructs are also introduced. Remember to always execute the code snippets within the lecture notes to understand Julia programming techniques.

  1. Approximate b(t)=t(π-t)(2π-t) on the interval [0,2π) by the following series and study the convergence behavior of the solution. The pseudo-matrix A(t) arising in the approximation is shown in each case

    1. Cosine series

      b(t)k=0nxkcos(kt),
      A(t)=[ 1 cos(t) cos(2t) cos(nt) ],A:n+1.
    2. Trigonometric series

      b(t)k=0n[xkcos(kt)+yksin(kt)],
      A(t)=[ 1 cos(t) sin(t) cos(2t) sin(2t) cos(nt) sin(nt) ],A(t):2n+1.

    3. Sine series

      b(t)k=1nyksin(kt),
      A(t)=[ sin(t) sin(2t) sin(nt) ],A:n.
    4. Triangle wave series

      b(t)k=1nzkWk(t),
      A(t)=[ W1(t) W2(t) Wn(t) ],A:n,

      with

      Wk(t)=1-4|12-14+kt2π|,

      where x is the fractional part of x, e.g., 1.15=0.15.

    Solution. Sample b(t) at points tj=(j-1)h, j=1,2,,m, with spacing h=2π/m, and let 𝒕 denote the vector with components tj. Let p denote the number of columns in the A(t) pseudo-matrix, i.e., the number of functions uk(t) entering into the approximation of b(t) by the linear combination

    fp(t)=k=1pckuk(t). (1)

    Table 1 defines ck, uk(t) for each of the four cases, with k=1,2,,p. Case b also conforms to this pattern since the presence of both cos(kt) and sin(kt) suggests the use of complex numbers

    bn(t)=k=0n[xkcos(kt)+yksin(kt)]=12k=0n[xk(eikt+e-ikt)-iyk(eikt-e-ikt)]

    bn(t)=12[k=0n(xk-iyk)eikt+k=0n(xk+iyk)e-ikt]=12[pn(t)+qn(t)].

    As expected for bn(t), pn(t),qn(t) are complex conjugates

    pn(t)=k=0n(xk-iyk)eikt=k=0n(xk+iyk)e-ikt=qn(t),

    hence only one need be computed and the expression

    fp(t)=2Re{k=1pcke-i(k-1)t}

    is obtained, indeed conforming to the same pattern as the other cases.

    Case ck uk(t)
    a yk cos((k-1)t)
    b xk+iyk e-i(k-1)t
    c yk sin(kt)
    d zk Wk(t)

    Table 1. Coefficient, basis function definitions.

    Problem solution consists of the following steps, leading to results in Fig. 1.

    Define b(t) and the basis functions uα(k,t), α{a,b,c,d} to be investigated.

    Define a function to compute the error in approximating b(t) by a series with p terms with coefficients determined by sampling at m points

    E(m,p)=||fp(𝒕)-b(𝒕)||/||b(𝒕)||,

    with b(𝒕),fp(𝒕)m vectors obtained by sampling b(t),fp(t) at 𝒕m. With 𝒄p the vector with components ck, fp(𝒕) is evaluated by the matrix-vector product

    fp(𝒕)=A(𝒕)𝒄.

    Test the error function by computing the coefficients for v(t)=cos(t) and w(t)=cos(t)+cos(5t) using basis set ua(k,t)=cos(kt). We should obtain zero error once enough terms are included.

    Define a function to construct a convergence plot by evaluating E(m,p) on a of range p values ε

    Choose sufficient sample points to resolve the function b(t), say m=100, and construct convergence plots for the four cases

    Figure 1. Comparison of convergence for different basis sets. No convergence is obtained for ua(k,t)=cos(kt) since the basis set is even but b(t) is odd. Convergence is observed for the other basis sets. Faster convergence is obtained for ub(k,t)=e-ikt,uc(k,t)=sin(kt), with ε10-3 (3 significant digits) obtained with p=11 terms. Convergence is significantly slower for the triangle functions ud(k,t)=Wk(t).

  2. Study the analytical theory underlying the above approximations by considering the following.

    1. State the convergence theorem for Fourier series and the Fourier coefficient formulas (see, e.g., [1]). Analytically compute the Fourier coefficients for b(t)=t(π-t)(2π-t). Use of a symbolic computation package (e.g., Maxima, Mathematica) eliminates tedious hand computation.

      Solution. For b: with a finite set {tj} of isolated discontinuity points,

      b(t)=limnk=0n[xkcos(kt)+yksin(kt)].

      At points of discontinuity

      limnk=0n[xkcos(kt)+yksin(kt)]=12[b(tj-)+b(tj+)].

      The Fourier coefficients are computed by (MATH529: L15)

      xk=1π02πb(t)cos(kt)dt=0,yk=1π02πb(t)sin(kt)dt=12k3.
    2. Compare the analytically computed Fourier coefficients with the numerical results obtained in Problem 1, a)-c). Assess the analytically predicted Fourier series convergence by comparison to the numerical results.

      Solution. The relevant basis is case b, and numerically computed coefficients are compared against analytical results in Fig. 2 .

      Figure 2. Numerical xk(), yk(×), recover analytical xk=0, yk=12/k3().

    3. Carry out series approximations as in Problem 1, a)-d) of

      c(t)=π34[H(t)-2H(.t-π).]

      where H(x) is the Heaviside step function

      H(x)={ 0 x<0 1 x>0 ..

      Solution. The steps of Problem 1 are repeated for c(t) leading to Fig. 3

      Define H(t),c(t)

      Sample the function c(t), and construct convergence plots for the four cases

      Figure 3. Comparison of convergence of approximation of c(t) for different basis sets. Slower convergence is observed by comparison to approximation of b(t). The fastest convergence is observed for the triangle wave basis Wk(t).

    4. Again, compare analytically evaluated Fourier coefficients with numerical results. How do the approximations of c(t) behave differently from those of b(t)?

      Solution. Plot b(t) and c(t) to gain insight into different behavior (Fig. 4). Note that c(t) is a discontinuous analogue of b(t).

      Figure 4. b(t) (blue), c(t) (red)

      The Fourier coefficients are now

      xk=1π02πc(t)cos(kt)dt=0,y2j+1=1π02πb(t)sin(kt)dt=π22j+1,y2j=0.

      Figure 5. Numerical yk(×), recovers analytical y2j+1=π2/(2j+1)().

      Convergence is obtained for both b(t) and c(t). Convergence is faster for b(t) in the continuous Fourier basis, while for c(t) it is faster in the discontinuous triangle wave basis. Convergence is slower for the discontinuous function c(t) with coefficient decay 1/k by comparison to the coefficient decay 1/k3 for the continuous function b(t).

Bibliography

[1]

Erwin Kreyszig. Advanced engineering mathematics. Hoboken, NJ : John Wiley, c2006., 9th ed. edition, 2006.