Assignment I

  1. (20 pts) Write a code that computes $x_n$,$r_n$,$p_n$,$q_n$, makes error analysis and tabulates the outcomes;
    $x_n =\frac{1}{3^n}$, approximated by (for n = 1, 2, )

    \begin{displaymath}
r_0 = 1 , r_n =\frac{1}{3}r_{n-1}\Longrightarrow\left(=\frac{A}{3^n}\right)
\end{displaymath}


    \begin{displaymath}
p_0 = 1 , p_1 =\frac{1}{3}, p_n =\frac{4}{3}p_{n-1} -\frac{1}{3}p_{n-2}\Longrightarrow\left(A\frac{1}{3^n}+B\right)
\end{displaymath}


    \begin{displaymath}
q_0 = 1 , q_1 =\frac{1}{3}, q_n =\frac{10}{3}q_{n-1} -q_{n-2}\Longrightarrow\left(A\frac{1}{3^n}+B3^n\right)
\end{displaymath}

    Generate a table for $x_n-r_n,x_n-p_n,x_n-q_n$, with errors introduced in the starting values: (should be similar to the Table 1)

    \begin{displaymath}
r_0 = 0.99996 , p_0 = q_0 = 1 , p_1 = q_1 = 0.33332
\end{displaymath}


    Table 1: The Error Sequences
    $x_n - r_n$ $x_n - p_n$ $x_n - q_n$
    0.0000400000 0.0000000000 0.0000000000
    0.0000133333 0.0000133333 0.0000013333
    0.0000044444 0.0000177778 0.0000444444
    0.0000014815 0.0000192593 0.0001348148
    0.0000004938 0.0000197531 0.0004049383
    0.0000001646 0.0000199177 0.0012149794
    0.0000000549 0.0000199726 0.0036449931
    0.0000000183 0.0000199909 0.0109349977
    0.0000000061 0.0000199970 0.0328049992
    0.0000000020 0.0000199990 0.0984149998
    0.0000000007 0.0000199997 0.2952449999


    Comment the behaviors of the errors for the each case.
  2. (20 pts) Write a code that computes values of this expression

    \begin{displaymath}
z=\frac{(x+y)^2-2xy-y^2}{x^2}
\end{displaymath}

    with different values of $x$ and $y$. (Hint: use $y=10000$ and change the x-value as $0.01,0.001,0.0001,,\ldots$)
    x=0.01;  y=10000;z=((x+y)^2-2*x*y-y^2)/x^2;
    x=0.001;  y=10000;z=((x+y)^2-2*x*y-y^2)/x^2
    x=0.0001;  y=10000;z=((x+y)^2-2*x*y-y^2)/x^2
    x=0.00001;  y=10000;z=((x+y)^2-2*x*y-y^2)/x^2
    x=0.000001;  y=10000;z=((x+y)^2-2*x*y-y^2)/x^2
    x=0.0000001;  y=10000;z=((x+y)^2-2*x*y-y^2)/x^2
    
  3. (60 pts) Write a MATLAB program for the given function to solve by using bisection, regula falsi, and Newton's methods.

    \begin{displaymath}
f(x)=4x + cos(x) - e^{x^2}
\end{displaymath}

    Your program should Compare and discuss the rate of convergence.
2005-07-03