Topic 10.6: Müller's Method (Matlab)

Contents Previous Chapter Start of Chapter Previous Topic Introduction Notes Theory HOWTO Examples Engineering Error Questions Matlab Maple Next Topic Next Chapter

Implementing Müller's method in Matlab is not that difficult:

eps_step = 1e-5;
eps_abs = 1e-5;
p = [1 2 3 4 2];
x = [0 -0.1 -0.2]';
y = polyval( p, x );
while ( true )
     V = vander( x - x(2) );
     c = V \ y;
     disc = sqrt( c(2)^2 - 4*c(1)*c(3) );

     % if ( real(c(2))*real(disc) + imag(c(2))*imag(disc) > 0 )

     if abs( c(2) + disc ) > abs( c(2) - disc )
         denom = c(2) + disc;
     else
         denom = c(2) - disc;
     end

     [roots(c)', -2*c(3)/denom, x'];

     x = [x(2), x(3), x(2) - 2*c(3)/denom]';

     y = [y(2), y(3), polyval( p, x(3) )]';

     if ( abs( x(2) - x(3) ) < eps_step && abs( y(3) ) < eps_abs )
        break;
     end
end
x(3)

Copyright ©2005 by Douglas Wilhelm Harder. All rights reserved.