ECE 602 BME I Nonlinear Equations in Biomedical
ECE 602 BME I Nonlinear Equations in Biomedical Engineering (Cont’d)
Newton-Raphson method • x 0: initial guess • Iterative formula: • Terminating condition: Convergence condition: x 0 should be close to x*.
Newton’s method for Nonlinear System • x 0: initial guess • Iterative formula: • Terminating condition: Convergence condition: x 0 should be close to x*.
Implementation Issues How to define a math function ? How to use a math function as an argument? Ex. function x=fn 2(fn, x 0) %fn: function name function f=fn 1(x) f=x. ^3 -10*x. ^2+29*x-20; x=feval(fn, x 0); >> f=fn 2('fn 1', 5) f= 0
Implementation Issues How to define a math function ? How to use a math function as an argument? Ex. function f=fn 3(v) x=v(1); y=v(2); f=zeros(2, 1); f(1)=x^2+y^2 -4; f(2)=x*y-1; >> x 0=[1; 1]; >> feval('fn 3', x 0) ans = -2 0
Implementation Issues How to define a math function ? How to use a math function as an argument? Ex. function jf=fn 4(v) %Jacobian matrix definition x=v(1); y=v(2); jf=zeros(2, 2); jf(1, : )=[2*x 2*y]; jf(2, : )=[y x]; >> x 0=[1; 1]; >> feval('fn 4', x 0) ans = 2 1
Implementation Issues Backslash or left matrix divide. If A is an N-by-N matrix and B is a column vector with N components, or a matrix with several such columns, then X = AB is the solution to the equation A*X = B computed by Gaussian elimination. A warning message is printed if A is badly scaled or nearly singular. >> A=rand(4, 4) A= 0. 9501 0. 2311 0. 6068 0. 4860 0. 8913 0. 7621 0. 4565 0. 0185 >> b=A*ones(4, 1) b= 3. 5846 2. 1761 1. 8550 1. 7021 >> x=Ab x= 1. 0000 0. 8214 0. 4447 0. 6154 0. 7919 0. 9218 0. 7382 0. 1763 0. 4057
- Slides: 7