HomeWork ONE

  1. 1.3

    a $ \epsilon_{\rm machine}\times \beta^{E_{min}}$, where machine epsilon $ \epsilon_{\rm machine}=1/beta^{p-1}$, $ \beta$ is the base of the system and $ E_{min}$ is lowest possible value of exponent.

    b $ \epsilon_{\rm machine}\times \beta^{E_{max}}$ with $ E_{max}$ being maximum value of exponent,


    $\displaystyle 2^{53-24}-1=536870911.$

  2. 1.8


    $\displaystyle \sum\limits_{k=0}^{1000}\frac{e^k}{e^k+1} =
\sum\limits_{k=0}^{1000}\frac{1}{e^{-k+1}} =1000.03583648423874/$

    Here we divided numerator and denominator by $ e^k$ to avoid overflow.


    $\displaystyle \sum\limits_{k=0}^{1000}\frac{\cosh k}{1+\sinh k} =
\sum\limits_{k=0}^{1000}\frac{1+e^{-2k}}{1+2 e^{-k}-e^{-2 k}}
= 1000.38056571994274.$

    Here we divided numerator and denominator by $ e^k$ to avoid overflow.


    $\displaystyle \sum\limits_{k=0}^{1000}\sqrt{3+e^k} -


    $\displaystyle \frac{\sum\limits_{k=0}^{1000}e^k}{\sum\limits_{n=0}^{1000} n e^n...
...00}e^{k-1000}}{\sum\limits_{n=0}^{1000} n e^{n-1000}} = 0.00100058231560098515.$

    Here we divided numerator and denominator by $ e^{1000}$ to avoid overflow.



    $\displaystyle X=\sum\limits_{k=1}^{1000}k\left[ \sin\left(\pi(k^{10}+1/k)\right)-

    Since $ \sin(\pi+x) = -\sin(x)$, and $ \sin[\pi-x]=\sin[x]$, and $ \sin[2 \pi+x] = \sin[x]$, and using the fact that even number raised to the power of 10 is even, and odd number raised to teh power of 10 is odd, we obtain

    $\displaystyle X=2 \sum\limits_{k=1}^{1000}(-1)^k k \sin\left(\frac{\pi}{k}\right)

  3. 1.9 Homer states

    $\displaystyle 3987^{12}+4365^{12}=4472^{12}.$

    Is it true?

    a If Horner right,

    $\displaystyle X_1= 3987^{12}+4365^{12}-4472^{12}$

    should be 0, yet Matlab returns $ 1.2119e+33$

    b If Horner is right,

    $\displaystyle X_2=\left(3987^{12}+4365^{12}\right)^{\frac{1}{12}}-4472$

    should be zero, yet Matlab returns $ 7.0577e-09$.

    c If Horner is right,

    $\displaystyle X_3=\frac{\left(3987^{12}+4365^{12}\right)}{4472^{12}}$

    should be $ 1$, yet Matlab returns $ 1.000000000018943$

    d If Horner is right,

    $\displaystyle X_4=\left[\left(3987^{12}+4365^{12}\right)
^{\frac{1}{12}}\right]^{12} -

    should be zero, yet Matlab returns $ 1.211616482290016e+33$

    e The product of two $ p$ digit numbers may have up to $ 2 p$ digits. Therefore $ 3987^{12}$ may have up to 48 digits, which is longer then Matlab's 16 digits. Therefore we can not use doubles in Matlab to either prove or disprove this conjecture.

    Note that $ X_1$ can be explicitly calculated on a computer with inifinite precision (check out vpa command in matlab), because it is an integer. Using the “sym” command, or Mathematica allows us to get the answer:

    $\displaystyle X_1=1211886809373872630985912112862690.$

  4. 1.11 Here we deal with

    $\displaystyle f(x)=\frac{e^x-1}{x},$

    for small values of $ x$. Expanding $ e^x\simeq 1+x,$ we obtain

    $\displaystyle f(x)\simeq \frac{(1+x)-1}{x}.$

    This is very close to the example we studied in class, so all information can be taken directly from lecture notes
  5. 1.13 Here we study for small $ x$ the function

    $\displaystyle f(x)=\frac{\ln(1-x)}{x}.$

    Taking into account that

    $\displaystyle \ln(1-x)\simeq -x - x^2/2 - x^3/3-x^4/4,$

    the numerator should be equal to $ x$ for small $ x$. Yet, the numerator is computed by first $ (1-x)$ and then taking the logarithm. Therefore for small values of $ x$ the numerator is approximately given by

    $\displaystyle (1-x)-1$

    we therefore may use information from lectures to characterize behaviour of this function.

  6. 1.17 a

    Use Taylor’s theorem to show that

    $\displaystyle \vert { \rm sin} x-{\rm sin} x_f \vert \le \vert x-x_f \vert$ (31)

    Denoting $ x=x_f+\delta$ and using

    $\displaystyle \sin(x=x_f+\delta) \simeq \sin(x)+\delta\cos(x_f),$

    we obtain

    $\displaystyle \sin(x)-\sin(x_f)\simeq \delta\cos(x_f).$

    Since $ \cos(x_f)\le 1$, we obtain (32).

    b Why

    $\displaystyle \vert x-x_f\vert\le \vert\tilde{ x_f} - \tilde{ \tilde{ x_f}}\vert$ (32)

    This is due to “rounding to nearest”, $ x$ is rounded to $ x_f$, and $ x_f$ is either $ \tilde{ x_f}$ or $ \tilde{ \tilde{ x_f}}$. In other words, the distance between a number and its floating point representation is less than half a distance between nearest two floaing point numbers.


    Since $ 2^E<x<2^{E+1}$ and $ 2^E<x_f<2^{E+1}$, we get $ \vert x-x_f\vert<2^E$. More precisely, $ x-x_f\le \epsilon
e^E$. Use this together with (32) and (33) to get

    $\displaystyle \vert\sin x-\sin x_f\vert\le \epsilon 2^{E-1}$ (33)

    d This question implies that

    $\displaystyle x<L\le 2^{E+1}.$     (34)

    If this property is not satisfied, then the result can not be obtained.

    To obtain this result, write

    $\displaystyle \epsilon 2^{E-1}=\frac{1}{4}\epsilon 2^{E+1},$

    then use (35).

    Author's note: in (d) the right hand side shoule be $ eps*L/2$ and in (e) the right hand side should be $ eps*(L+2)/2$.

    e The RHS can be rewritten as

    $\displaystyle \frac{1}{4}\epsilon(L+4) = \frac{\epsilon L}{4}+\epsilon.$

    Now use $ \vert sin x_f-s_f\vert\le \epsilon$ to obtain the desired result.

    f Using $ \epsilon=10^{-16}$ we get $ L=4E8$. Picture shows that $ 10^{-8}$ accuracy is obtained at $ k=25$, i.e. $ L\simeq 3E7$. In other words the estimate is optimistic.