my_newton - x for i = 1:max_iter xo = xn xn =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function [root,rhist,niter,error] = my_newton(fh,dfh,xo,tol,tol_type, . .. max_iter) switch tol_type s case 'a' termination = @(xn,xo) abs(xn-xo) <= tol; case 'r' termination = @(xn,xo) abs(xn-xo)/abs(xo) <= tol; case 'f' termination = @(xn,xo) abs(feval(fh,xn))<=tol; end e rhist = [xo]; niter = 0; xn = xo;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x for i = 1:max_iter xo = xn; xn = xo-fh(xn)/dfh(xn); rhist = [rhist xn]; niter = niter+1; if termination(xn,xo) == 1 break end end e switch tol_type case 'a' error = abs(xn-xo); case 'r' error = abs(xn-xo)/abs(xo); case 'f' error = abs(feval(fh,xn)); end e root = xn;...
View Full Document

This note was uploaded on 02/18/2010 for the course ENGINEERIN 7 taught by Professor Patzek during the Spring '08 term at Berkeley.

Ask a homework question - tutors are online