MATH661 Homework 3 - Least squares problems

Posted: 09/09/21

Due: 09/15/21, 11:55PM

This assigment addresses one of the fundamental topics within scientific computation: finding economical descriptions of complex objects. Some object is described by 𝒚m (with m typically large), and a reduced description is sought by linear combination 𝑨𝒙, with 𝑨m×n (n<m, often nm). The surprisingly simple Euclidean geometry of Fig. 1 (which should be committed to memory) will be shown to have wide-ranging applicability to many different types of problems. The error (or residual) in approximating 𝒚 by 𝑨𝒙 is defined as

𝒓=𝒃-𝑨𝒙,

and 2-norm minimization defines the least-squares problem

min𝒙m||𝒃-𝑨𝒙||.

Figure 1. Least squares (2-norm error minimization) problem.

1Track 1

Consider data 𝒟={(ti,yi)|i=1,2,,m.} obtained by sampling a function f:, with yi=f(ti). An approximation is sought by linear combination

f(t)x1a1(t)+x2a2(t)++xnan(t).

Introduce the vector-valued function A:n (organized as a row vector)

A(t)=[ a1(t) a2(t) an(t) ],

such that

f(t)A(t)𝒙,𝒙=[ x1 x2 xn ]T.

With 𝒕=[ t1 t2 tm ]T a sampling of the function domain, a matrix is defined by

𝑨=A(𝒕)𝒙=[ a1(𝒕) a2(𝒕) an(𝒕) ]𝒙m×n.

Tasks. In each exercise below, construct the least-squares approximant for the stated range of n𝒩, sample points 𝒕, and choice of A(t). Plot in a single figure all components of A(t). Plot the approximants, as well as f in a single figure. Construct a convergence plot of the approximations by representation of point data ={(logn,log||𝒚-𝑨𝒙||)|𝑨m×n,n𝒩.}. For the largest value of n within 𝒩, construct a figure superimposing increasing number of sampling points, m. Comment on what you observe in each individual exercise. Also compare results from the different exercises.

  1. Start with the classical example due to Runge (1901)

    f:[-1,1],f(t)=1(1+25t2),ti=2(i-1)m-1-1, ={16,32,64,128,256},𝒩={4,8,16,32}, A(t)=[ 1 t t2 tn-1 ].

    Solution. With 𝒕m denoting the sampling point vector, and 𝒚m, the function values at the sample points, the least squares problem is

    min𝒙n||𝒚-𝑨𝒙||,

    where

    𝑨=[ 𝟏 𝒕 𝒕n-1 ].

    The solution to the least squares problem

    𝒛=argmin𝒙n||𝒚-𝑨𝒙||,

    furnishes the approximation

    f(t)f(t)=A(t)𝒛,

    that can be sampled at Mm points to assess approximation error.

    When carrying convergence studies such as these, it is convenient to define functions for common tasks:

    sample. Returns a sample of f:[a,b] at m equidistant points

    plotLSQ. Constructs a figure with plots of:

    1. The m sample points (i.e., data) represented as black dots;

    2. The function sampled at more points, i.e., Mm;

    3. The approximation sampled at M points

    This problem solution is obtained by:

    1. defining the function f

      Runge(t)=1/(1+25*t^2);
    2. defining the basis

      function MonomialBasis(t,n)
        m=size(t)[1]; A=ones(m,1);
        for j=1:n-1    
          A = [A t.^j]
        end
        return A
      end;
    3. Invoking plotLSQ with appropriate parameters

      clf(); plotLSQ(-1,1,Runge,MonomialBasis,16,4,64);
      FigPrefix=homedir()*"/courses/MATH661/images/H03";
      savefig(FigPrefix*"Fig01.eps")

      Figure 2. Least squares approximant (red) of Runge function (blue) sampled at (black dots).

    Once the above are defined cycling through the parameter ranges is straightforward (open figure folds to see code).

    Figure 3. Effect of increasing number of monomial basis functions in least squares approximation of Runge function.

  2. Instead of the equidistant point samples of the Runge example above use the Chebyshev nodes

    ti=cos(2i-12mπ),

    keeping other parameters as in Problem 1.

  3. Instead of the monomial family of the Runge example, use the Fourier basis

    A(t)=[ 1 cosπt sinπt cosπnt sinπnt ]

    keeping other parameters as in Problem 1. In this case 𝑨m×(2n+1).

  4. Instead of the monomial family of the Runge example, use the piecewise linear B-spline basis

    A(t)=[ N1(t) N2(t) Nn(t) ],
    Ni(t)={ 0, t<ti-1 t-ti-1h ti-1t<ti ti+1-th tit<ti+1 0 ti+1<t .,h=2m-1,

    keeping other parameters as in Problem 1.

2Track 2

  1. If 𝑸m×n has orthonormal columns, prove that 𝑷𝑸=𝑸𝑸 is an orthogonal projector onto C(𝑸). Determine the expression of 𝑷𝑨, the projector onto C(𝑨), with 𝑨m×n. Compare the number of arithmetic operations required to compute 𝒚=𝑷𝑨𝒙, by comparison to first determining the QR factorization, 𝑨=𝑸𝑹, and then computing 𝒚=𝑸𝑸𝒙.

  2. Continuing Problem 1, determine ||𝑷𝑸||2, and express ||𝑷𝑨||2 in terms of the singular value decomposition of 𝑨. Comment the result, considering, say, length of shadows at various times of day.

  3. A matrix 𝑨=[aij]m×n is said to be banded with bandwidth B if aij=0 for |i-j|>B. Implement the modified Gram-Schmidt algorithm for 𝑨m×n a banded matrix with bandwidth B using as few arithmetic operations as possible.

  4. Solve Problem 1, Track 1.

  5. Solve Problem 4, Track 1.

  6. In Problem 1, Track 1, replace the monomial basis with the Legendre polynomials, whose samples are determined by QR decomposition 𝑸𝑹=𝑨. The resulting least squares problem is now

    min𝒙n||𝒚-𝑸𝒙||2.