Answer to Quiz 11 Fri 18 Nov 2005

  1. Newton's method to approximate a root of a function f(x) = 0 is defined \newline by x(k+1) = x(k) - f(x(k))/f'(x(k)), k=0,1,...
    1. Complete the following prototype to perform one step with Newton's method:
      function y = newton_step(f,df,x)
      %
      %  The function y = newton_step(f,df,x) does one step with newton's 
      %  method on f(x) = 0, with derivative function in df, starting at x.
      %
      
    2. Give the MATLAB command to use one step of Newton's method to compute an accurate approximation of the solution to sin(x) = 0, starting at x = 3.

      Also give the value returned by your newton_step.

    Answer:

    1. function y = newton_step(f,df,x)
      %
      %  The function y = newton_step(f,df,x) does one step with newton's 
      %  method on f(x) = 0, with derivative function in df, starting at x.
      %
      y = x - feval(f,x)/feval(df,x);
      
    2.  y = newton_step('sin','cos',3)
       returns 3.1425
      
  2. Give all MATLAB commands to make a bowl as a surface of revolution, around the vertical axis. The bottom of the bowl is at the origin and its height equals one. The shape of the bowl is determined by the square root function, i.e.: revolute r = sqrt(t), for t in [0,1], around the vertical axis. The plot you should obtain is shown below.

    Answer:

          t = 0:0.01:1;
          r = sqrt(t);
          cylinder(r);