mm245/ma260 lab2


http://www.maths.nuigalway.ie/~gettrick/teach/mm245/labs/l2.html




You should first read the code in fixedp1.m at http://www.maths.nuigalway.ie/~gettrick/teach/mm245/labs/matlab/ and try to understand it. For this lab

  1. Consider the "problem" of finding the square root of two, i.e. the root of f(x)=x**2-2. Consider the fixed point iterations
    • g1(x) = x/2 + 1/x
    • g2(x) = 2*x/3 + 2/(3*x)
    Calculate the order of convergence for both g1(x) and g2(x). (You don't need MATLAB/SCILAB/OCTAVE to do this!)
  2. Write MATLAB code to carry out iterations using g1(x) starting at the point x0 = 100. How many iterations are needed to obtain the square root of two to 9 decimal places (i.e. 1.414213562)?
  3. Write MATLAB code to carry out iterations using g2(x) starting at the point x0 = 2. How many iterations are needed to obtain the square root of two to 9 decimal places (i.e. 1.414213562)?
  4. For your second MATLAB program (using g2(x)): Determine the relative error at each step in your calculation, using 1.414213562 as the actual square root of two.


© NUI, Galway