MATH661 S00 - Number approximation

Posted: 08/21/23

Due: 08/30/23, 11:59PM

Tracks 1 & 2: 1-4. Track 2: 5.

This homework serves as an introduction to number approximation techniques and a familiarization with homework drafting and submission procedures. No grade points are awarded, but comments on proper assignment drafting are returned.

Solution drafting notes.

Take note of the following aspects of the model solution. The letter in the list below will be used in comments on your submitted solution.

  1. Hints on how to approach your solution are deleted from the work you turn in.

  2. Correct punctuation is used in mathematical statements.

  3. Present concise results.

  4. Favor presentation of results as well-constructed plots or tables that synthesize performed computations. Plots must be labeled, inserted into your document (Insert->Image->Insert image ...) into a figure environment (Insert->Image->Small figure) and appropriately sized. Tables must be labeled and inserted into a table environment (Insert->Table->Big table).

  5. When a question specifically requests presentation of code, include the code in the main text of your solution. Otherwise, include code that was used to obtain your results inside of a fold (Insert->Fold->Folded->Default). Submit your draft with all folds closed, which should result in a coherent presentation of your work.

  6. Include brief comments on the intent of the coding instructions.

  7. Break up long sequences of code (Focus->Session->Split session) into commented chunks.

  8. Ensure variables in code correspond to notation used in mathematical formulas.

  9. Immediately test functions to ensure they behave as intended.

  10. Identify generic aspects of a problem and code these into separate functions, e.g., a general function to evaluate continued fractions that can be reused or tested on a simple cases.

  11. Always add a conclusion to your presentation of results.

  12. State relevant theory, and verify assumptions of the theory.

  13. Consider alternative interpretations of a problem, even if you choose to solve only one formulation.

  14. Recognize structures within complicated expressions.

  15. Recognize complicated formulations, and first attempt the simplest possible case. Within allowable time constraints either start work on the more complicated formulation or state the difficulties.

  1. Construct a convergence plot in logarithmic coordinates of the Stern continued fraction

    π2=1-

    Identify the terms in the general expression of a continued fraction

    Fn=b0+Kk=1nakbk.

    Compare with the additive approximation of the Leibniz series

    π4=1-13+15-17+19-.,

    Estimate the rate and order of convergence for both approximations.

    Solution. (a) Identification of terms: the first few terms are

    b0=1,b1=3,b2=1,b3=3,b4=1,b5=3,
    a1=-11,a2=-23=-6,a3=-12=-2,a4=-45=-20,a5=-34=-12.(b)

    With l=kmod2, t=2l-k, k, obtain bk=1+2l, and ak=t(1-t) for k>1. (c)

    Figure 1. Comparison of convergence of Leibniz series (×) and Stern continued fraction (). (d)

    For large enough n, the distance of a term sequence to the limit dn=|xn-x| satisfies

    dn+1sdnq,dnsdn-1q,

    whence

    dn+1dn(dndn-1)qqlogdn+1-logdnlogdn-logdn-1,

    and then

    sdn+1/dnq.

    Results are presented in the following table, with both sequences exhibiting close to linear convergence. (k)

    Leibniz Stern
    Rate s 0.963 0.938
    Order q 0.995 0.990

    Table 1. Convergence behavior of Leibniz series and Stern continued fraction (d)

  2. Apply convergence acceleration to both the above approximations involving π. Construct the convergence plot of the accelerated sequences, and estimate the new rate and order of convergence.

    Solution. (a) Since both the Leibniz and the Stern sequences exhibit close to linear convergence, Aitken acceleration is applicable (though not guaranteed to provide faster convergence since it is an extrapolation).

    Figure 2. Aitken acceleration of Leibniz and Stern sequences. While second-order convergence is obtained for the Leibniz sequence, the modulo 2 alternating coefficients yield no increase in order of convergence for the Stern sequence (k).

    Generate terms in the Leibniz, Stern sequences

    N=40; n=1:N; L=Leibniz.(n); S=ContFrac.(n,aS,bS);

    Define a function that carries out Aitken acceleration. (j)

    function Aitken(x)
      n=maximum(size(x)); a=copy(x);
      for k=3:n
        Δx = x[k] - x[k-1]
        Δ2x = x[k] - 2*x[k-1] + x[k-2]
        a[k] = x[k] - Δx^2/Δ2x
      end
      return a
    end;
    AL = Aitken(L); AS = Aitken(S);

    Construct plot of errors for both original and accelerated sequences

    errL=log.(abs.(L .- π/4)); errAL=log.(abs.(AL .- π/4));
    errS=log.(abs.(S .- π/2)); errAS=log.(abs.(AS .- π/2));
    clf(); plot(log.(n),errL,"-o"); plot(log.(n),errS,"-x"); plot(log.(n),errAL,"o"); plot(log.(n),errAS,"x"); xlabel("log(n)"); ylabel("log(err)"); title("Aitken-accelerated Leibniz/Stern convergence"); grid("on"); plot([2,4],[-6,-8],"-"); plot([2,4],[-6,-10],"-");
    savefig(homedir()*"/courses/MATH661/homework/H00/Fig02.eps")
  3. Completely state the mathematical problem of taking the nth root of a positive real, n. Find the absolute and relative condition numbers.

    Solution. Within the framework of defining a mathematical problem as a function f:XY (l), the choices

    f(x)=x1/n,

    with X=+=(0,), Y=, can be made. Other options (m) include X=+× treating n as a variable or considering the framework of multivalued functions (regularized by cuts in the complex plane) for which Y=. Since f is differentiable, the absolute condition number is given by the derivative

    κ^f(x)=1nx1/n-1.

    The relative condition number is then

    κf(x)=1nx1/n-1x1/nx=1n.
  4. Completely state the mathematical problem of finding the roots of the cubic polynomial p(x)=x3+px+q, using the Cardano [2] formula. Find the absolute and relative condition numbers.

    Solution. Assuming (p,q)2, then one real root is obtained as

    f(p,q)=g(p,q)3+h(p,q)3,

    where

    g(p,q)=-q2+D(p,q),h(p,q)=-q2-D(p,q),D(p,q)=q24+p327,(n)

    and D(p,q) is assumed to be positive. In this case X=2, Y=, though in general (m) p,q might be complex. The function f is a composition of differentiable functions, so the condition number may be evaluated as the norm of the gradient

    κ^f=||f||=13||g-2/3g+h-2/3h||.

    Further calculation gives

    g=[ 0 -1/2 ]+12D-1/2D,g=[ 0 -1/2 ]-12D-1/2D,
    D=[ p2/9 q/2 ].

    The relative condition number can be stated

    κ^f=||f|||f|(p2+q2)1/2,(n)

    choosing the 2-norm in X.

  5. Completely state the mathematical problem of solving the initial value problem for an ordinary differential equation of first order. Use Lyapunov exponents [1] to find the absolute condition number.

    Solution. For the initial value problem (IVP) expressed in autonomous form (always possible) (l)

    y'=s(y),y(0)=y0,

    the problem inputs are the slope function s that has to be Lipschitz continuous, sCk,1 to obtain a unique solution (l) and the initial value y0. The definition of the mathematical problem is then X=Ck,1×, Y=C. In this formulation the condition number requires the definition of the derivative of a function (i.e., the solution y) with respect to another function (the slope s). (o)

    Since the Lyapunov exponent L quantifies the rate of separation of trajectories upon infinitesimal perturbation of the initial condition δy0, in the simpler case of considering s fixed, the condition number is identical to the Lyapunov exponent, κ^=eL.

Bibliography

[1]

Luís Barreira. Lyapunov Exponents. Springer International Publishing, Cham, 2017.

[2]

Girolamo Cardano. Ars magna or The rules of algebra. New York : Dover, 1993.