MATH661 Homework 1 - Number approximation

Posted: 08/23/21

Due: 08/30/21, 11:55PM

  1. Construct a convergence plot in logarithmic coordinates for the Leibniz series approximation of π. Estimate the rate and order of convergence.

    Solution. The convergence of the Leibniz series partial sum sequence {Ln}n

    Ln=k=0n(-1)k2k+1,limnLn=π4,

    is shown in Fig. 1, and can be visually estimated to converge with order p=1. The rate of convergence is

    r=limnLn+1Ln=limn(1+(-1)n+1(2n+1)Ln)=1.

    Figure 1. Convergence of Leibniz series

    N=200; n=20:20:N;
    function Leibniz(n)
      k=0:n
      sum((-1).^k ./ (2*k.+1))
    end

    Leibniz

    err=log.(abs.(Leibniz.(n) .- π/4));
    clf(); plot(log.(n),err,"-o"); xlabel("log(n)"); ylabel("log(err)"); title("Leibniz series convergence"); grid("on"); plot([3,4],[-5,-7],"-"); plot([3,4],[-5,-6],"-");
    savefig(homedir()*"/courses/MATH661/images/H01Fig01.eps")
  2. Apply Aitken acceleration to the Leibniz partial sums sequence. Construct the convergence plot. Estimate the rate and order of convergence.

    Solution. The Aitken-accelerated sequence {An}n has general term

    An=Ln-(Ln-Ln-1)2Ln-2Ln-1+Ln-2,

    with convergence plot shown in Fig. 2, indicating faster than quadratic growth.

    Figure 2. Convergence of Aitken acceleration of Leibniz series

    N=40; n=1:N; L=Leibniz.(n); A=copy(L);
    for n=3:N
      ΔL = L[n] - L[n-1]
      Δ2L = L[n] - 2*L[n-1] + L[n-2]
      A[n] = L[n] - ΔL^2/Δ2L
    end
    errL=log.(abs.(L .- π/4)); errA=log.(abs.(A .- π/4));
    clf(); plot(log.(n),errL,"-o"); plot(log.(n),errA,"-x"); xlabel("log(n)"); ylabel("log(err)"); title("Aitken-accelerated Leibniz series convergence"); grid("on"); plot([2,4],[-6,-8],"-"); plot([2,4],[-6,-10],"-");
    savefig(homedir()*"/courses/MATH661/images/H01Fig02.eps")
  3. Construct a convergence plot for the Ramanujan series approximation of π. Estimate the rate and order of convergence.

    Solution. The general term

    rk=(4k)!(1103+26390k)(k!)43964k

    in the Ramanujuan series

    Rn=229801k=0n(4k)!(1103+26390k)(k!)43964k,limnRn=1π,

    decreases rapidly. Applying Stirling's formula lnn!nln-n (valid for large n), gives

    lnrk(4k)ln4k-4k+ln(1103+26390k)-4(klnk-k)-4kln396,
    lnrk-4kln99+ln(1103+26390k)
    rk=99-4k(1103+26390k)

    Since r0=1103103, terms smaller than 103ϵ (ϵ is machine epsilon) would not appreaciably contribute to the sum

    ε=eps(Float64); kmax = log(10^3*ε)/(-4*log(99))

    1.5851544170976106

    The above computation indicates that 2 terms of the sum should already give an approximation within machine precision.

    r(k) = factorial(4*k)*(1103.0+26390*k)/(factorial(k))^4/396^(4*k)

    r

    r.(1:5)

    [ 2.6831974348925308e-5 -3.383976671091512e-11 3.2409901671873466e-9 8.916491639979272e-7 -0.00021134339512742683 ] (1)

    (4k)! (1103+26390k)
    (k!)4 3964k

    Figure 3. Convergence of Ramanujan series

    N=200; n=20:20:N;
    function Leibniz(n)
      k=0:n
      sum((-1).^k ./ (2*k.+1))
    end

    Leibniz

    err=log.(abs.(Leibniz.(n) .- π/4));
    clf(); plot(log.(n),err,"-o"); xlabel("log(n)"); ylabel("log(err)"); title("Leibniz series convergence"); grid("on"); plot([3,4],[-5,-7],"-"); plot([3,4],[-5,-6],"-");
    savefig(homedir()*"/courses/MATH661/images/H01Fig01.eps")
  4. Construct a convergence plot for the continued fraction approximation of π. Estimate the rate and order of convergence.

  5. Completely state the mathematical problem of computing the absolute value

    |x|,x.

    Find the absolute and relative condition numbers.

    Solution. According to Demmel [?]

  6. Completely state the mathematical problem of computing a difference.

    x1-x2,x1,x2.

    Find the absolute and relative condition numbers.

Bibliography