MATH661 HW07 - Least squares, minimax

Posted: 10/18/23

Due: 10/25/23, 11:59PM

These exercises focus on midterm examination preparation.

1Track 1

  1. Find the polynomial of least degree that interpolates the data π’Ÿ={(xi,yi),i=0,1,…,n}={(3,10),(7,146),(1,2),(2,1)}.

    Solution. Table of divided differences

    i xi yi [yi,yi-1] [yi,yi-1,yi-2] [yi,yi-1,yi-2,yi-3] 0 3 10 - - - 1 7 146 34 - - 2 1 2 24 5 - 3 2 1 -1 5 0 ,

    leads to p2(t)=10+34(t-3)+5(t-3)(t-7).

  2. Find the polynomial of least degree that interpolates the data π’Ÿ={(xi,yi,yi'),i=0,1,…,n}=π’Ÿ={(3,10,14),(1,2,-6)}.

    Solution. Table of divided differences with repetitions

    i xi yi [yi,yi-1] [yi,yi-1,yi-2] [yi,yi-1,yi-2,yi-3] 0 3 10 - - - 0 3 10 y0'=14 - - 1 1 2 4 5 - 1 1 2 y1'=-6 5 0 ,

    leads to p2(t)=10+14(t-3)+5(t-3)2.

  3. Find the polynomial of least degree that interpolates the data π’Ÿ={(xi,yi,yi',yi''),i=0,1,…,n}=π’Ÿ={(1,2,-6,10)}.

    Solution. Table of divided differences with repetitions

    i xi yi [yi,yi-1] [yi,yi-1,yi-2] [yi,yi-1,yi-2,yi-3] 0 1 2 - - - 0 1 2 y0'=-6 - - 0 1 2 y0'=-6 y0''=10 - ,

    leads to p2(t)=2-6(t-1)+102(t-1)2.

  4. Find a,b,c,d such that

    S(x)={ 1-2x x∈(-∞,-3] a+bx+cx2+dx3 x∈[-3,4] 157-32x x∈[4,∞) .,

    is a natural spline on the [-3,4] interval.

    Solution. Continuity of function conditions:

    atx=-3β‡’1-2(-3)=7=a+b(-3)+c(-3)2+d(-3)3

    atx=4β‡’a+b(4)+c(4)2+d(4)3=157-32(4)=29

    Continuity of function derivative conditions:

    atx=-3β‡’-2=b+2c(-3)+3d(-3)2

    atx=4β‡’b+2c(4)+3d(4)2=-32.

    Obtain system

    { a-3b+9c-27d = 7 a+4b+16c+64d = 29 b-6c+27d = -2 b+8c+48d = -32 .,

    with solution {a→12763343,b→5056343,c→-312343,d→-282343}.

  5. Apply the Gram-Schmidt algorithm to orthonormalize the function set {1,t,t2} with respect to the scalar product

    (f,g)=-1+1f(t)g(t)dt.

    Solution. Obtain Ο†0(t)=1/(1,1)=1/2. Compute v1(t)=t-(t,Ο†0)Ο†0=t, and bring to unit norm

    Ο†1(t)=t/(t,t)=32t.

    Finally, compute

    v2(t)=t2-(t2,Ο†1)Ο†1(t)-(t2,Ο†0)Ο†0(t)=t2-1/3.

    Normalize to obtain

    Ο†2(t)=v2(t)/(v2,v2)=458(t2-1/3).

  6. Let {Ο†0(t),Ο†1(t),Ο†2(t)} denote the orthonormalized set found above. Find the best 2-norm approximant g(t)=c0Ο†0(t)+c1Ο†1(t)+c2Ο†2(t) of f(t)=sin(Ο€t/2) on the interval [-1,1].

    Solution. Since f is odd and Ο†0,Ο†2 are even deduce c0=c2=0. For c1 compute

    c1=(Ο†1,f)=8Ο€223.

  7. As above, find the best 2-norm approximant of f(t)=cos(Ο€t/2) on the interval [-1,1].

    Solution. As above, now c1=0, and compute

    c0=(Ο†0,f)=22Ο€,c2=(Ο†2,f)=210(Ο€2-12)Ο€3.

  8. Find the best approximant g(t)=Ξ»t of f(t)=sint on the interval [0,Ο€/2] in the ∞-norm.

    Solution. The error e(t)=sint-Ξ»t has a local extremum at e'(ΞΎ)=cosΞΎ-Ξ»=0β‡’ΞΎ=arccos(Ξ»), and an endpoint extremum at t=Ο€/2. Best approximant obtained when -e(Ο€/2)=e(ΞΎ)β‡’

    λπ/2-1=sinΞΎ-λξ⇒λπ/2-1=1-Ξ»2-Ξ»arccos(Ξ»).

    A numerical procedure can be used to to find Ξ», the root of the above equation.

2Track 2

  1. In the limit x1β†’x0 the divided difference

    f[x0,x1]=[y1,y0]=y1-y0x1-x0,yi=f(xi),i=0,1,

    has limit f[x0,x1]β†’f'(x0). Write and establish the validity of the finite difference form of the product rule (fg)'=f'g+fg'.

    Solution. Let yi=f(xi),zi=g(xi),wi=(fg)(xi)=f(xi)g(xi)=yizi. The divided difference of the product is

    (fg)[x0,x1]=[w1,w0]=w1-w0x1-x0=y1z1-y0z0x1-x0.

    The product derivative rule suggests

    [w1,w0]=[y1,y0]zj+yk[z1,z0],

    leading to

    y1z1-y0z0=(y1-y0)zj+yk(z1-z0),

    and identification j=1, k=0 and product rule

    [w1,w0]=[y1,y0]z1+y0[z1,z0],

    or

    (fg)[x0,x1]=f[x0,x1]g[x1]+f[x0]g[x0,x1].

  2. Repeat the above for second order finite differences and (fg)''=f''g+2f'g'+fg''.

    Solution. Generalize above result to

    (fg)[x0,x1,x2]=f[x0,x1,x2]g[x2]+f[x0,x1]g[x1,x2]+f[x1,x2]g[x0,x1]+f[x0]g[x0,x1,x2]

  3. A natural cubic spline has zero curvature at the end points. Prove that of all cubic spline interpolations of data π’Ÿ={(xi,yi=f(xi)),i=0,1,…,n}, the natural spline S(t) curvature two-norm is bounded by the function curvature two-norm

    x0xn[S''(t)]2dtβ©½x0xn[f''(t)]2dt.

    Solution. Consider the Hilbert space L2[x0,xn]={f|f:[x0,xn]→ℝ,βˆƒMβˆˆβ„||f||β©½M.} of square integrable functions with scalar product, norm

    (f,g)=x0xnf(t)g(t)dt,||f||2=(f,f).

    The above statement is rewritten as

    ||S''||2β©½||f''||2.

    Let g=f-S to obtain

    ||f''||2=(g''+S'',g''+S'')=||S''||2+||g''||2+2(S'',g''),

    and the requested inequality holds if

    (S'',g'')β©Ύ0.

    With Si:[xi-1,xi]→ℝ, Si(t)=ai(t-xi-1)3+bi(t-xi-1)2+mi(t-xi-1)+yi-1, integrate over subintervals

    x0xnS''(t)g''(t)dt=i=1nxi-1xiSi''(t)g''(t)dt. (1)

    Integrate by parts

    xi-1xiSi''(t)g''(t)dt=[S''(t)g'(t)]xi-1xi-xi-1xiSi'''(t)g'(t)dt,

    note that Si'''(t)=ci is constant, and replace in (1) to obtain

    x0xnS''(t)g''(t)dt=i=1n[S''(xi)g'(xi)-S''(xi-1)g'(xi-1)]-i=1ncixi-1xig'(t)dt⇒

    x0xnS''(t)g''(t)dt=[S''(x1)g'(x1)-S''(x0)g'(x0)]+[S''(x2)g'(x2)-S''(x1)g'(x1)]+…

    [S''(xn)g'(xn)-S''(xn-1)g'(xn-1)]-i=1nci[g(xi)-g(xi-1)].

    At nodes g(xi)=f(xi)-S(xi)=0 due to the interpolation condition and terms cancel out giving

    x0xnS''(t)g''(t)dt=S''(xn)g'(xn)-S''(x0)g'(x0).

    For natural end conditions S''(xn)=S''(x0)=0, hence

    (S'',g'')=x0xnS''(t)g''(t)dt=0β‡’||f''||2=||S''||2+||g''||2β©Ύ||S''||2.

    Note that this leads to

    ||f''||2=||S''||2+||g''||2,

    a Pythagorean theorem, stating that the projection of f'' onto space of first-degree splines S'' is orthogonal.

  4. Find a,b,c,d such that

    |e(1)|=|e(0)|β‡’|cosh1-a-b|=|1-a|β‡’
    S(x)={ 1-2x x∈(-∞,-3] a+bx+cx2+dx3 x∈[-3,4] 157-32x x∈[4,∞) .,

    is a natural spline on the [-3,4] interval.

    Solution. See above.

  5. Present an analysis of the conditioning of quadratic spline interpolation.

    Solution. The problem of quadratic spline interpolation is stated as (𝒙,π’š)β†’f𝒔, and from L21 the slope system is

    si-1+si=2hi(yi-yi-1),i=1,2,…,n,

    so the problem is linear with a condition number bounded by that of the above bidiagonal matrix 𝑺

    ΞΊfβ©½ΞΊ(𝑺),𝑺=[ 1 1 1 1 1 β‹± β‹± 1 1 ],𝑨=𝑺T𝑺=[ 2 1 1 2 1 1 2 1 β‹± β‹± 1 2 1 1 1 ].

    Carry out a numerical experiment.

    using SparseArrays
    function S(m)
      spdiagm(0 => ones(m), -1 => ones(m-1))
    end;
    collect(S(8))

    [ 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 ] (2)

    r=10:10:100; cond.(Matrix.(S.(r))) ./ r

    [ 1.3232029812481902 1.3015595822121873 1.2928867470799783 1.2882662782812822 1.2854017106315976 1.2834532213987946 1.2820423475124278 1.2809737095514466 1.2801363174342515 1.279462470845778 ] (3)

    r=100:25:250; cond.(Matrix.(S.(r))) ./ r

    [ 1.279462470845778 1.2782407173662882 1.2774198940886343 1.2768304891052986 1.2763867360563506 1.2760405866745244 1.2757630315067576 ] (4)

    r=250:250:1000; cond.(Matrix.(S.(r))) ./ r

    [ 1.2757630315067576 1.2745070304498798 1.2740858129880002 1.273874725330468 ] (5)

    The above suggests 𝑺 has a condition number ΞΊ(𝑺)=π’ͺ(m), ΞΊ(𝑺)β‰…1.27m, a well-conditioned problem.

  6. Apply the Gram-Schmidt algorithm to orthonormalize the function set {1,t,t2} with respect to the scalar product

    (f,g)=-1+1f(t)g(t)1-t2dt.

    Solution. As above, obtain Chebyshev polynomials.

  7. Find the best approximant g(t)=a+bt of f(t)=sint on the interval [0,Ο€/2] in the 2-norm and the ∞-norm.

    Solution. See Midterm2 solution.

  8. Prove that best inf-norm approximant of f:[-1,1]→ℝ, f(t)=cosh(t) by a quadratic polynomial has form p2(t)=a+bt2, with b=cosh1-1. Compute a.

    Solution. Since f is even, p2 is also even, and restrict to t∈[0,1]. Equioscillation theorem implies that error e(t)=cosht-(a+bt2) satisfies