Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Solution of Nonlinear Equation (b) Dr. Asaf Varol

Similar presentations


Presentation on theme: "1 Solution of Nonlinear Equation (b) Dr. Asaf Varol"— Presentation transcript:

1 1 Solution of Nonlinear Equation (b) Dr. Asaf Varol

2 2 Secant Method Similar approach as the Newton-Raphson method Differs because the derivative does not need to be calculated analytically, which can be a great advantage F(x i ) = [F(x i ) - F(x i-1 )]/(x i – x i-1 ) Disadvantage is that two initial guesses are needed instead of one

3 3 Graphical Interpretation of Newton-Raphson and Secant Method

4 4 Example: Secant Method Water flow from a tower at a height h, through a pipe of diameter D and length L which is connected to the tower running vertically downward and then laid horizontally to the desired point of delivery. For this system the following equation for the flow rate Q is found. Find the roots using the Secant Method.

5 5 Matlab Program

6 6 Result for Secant Method

7 7 Multiplicity of Roots and Newton-Based Methods In some situations, one root can fulfill the role of being a root more than one time. For example, the equation F(x) = x 3 - x 2 - x + 1= (x + 1)(x - 1)2 = 0 has three roots, namely x = -1, and x = 1 with a multiplicity of two Using l’Hospital’s Rule, the Newton-Raphson method can be modified x i+1 = x i - F(x i )/F  (x i ) Or, if the second derivative is also zero then l'Hospital's rule can be applied once more to obtain x i+1 = x i - F  (x i )/F  (x i )

8 8 Multiplicity of Roots and Newton-Based Methods

9 9 Example E2.4.1 Problem: Apply Newton-Raphson method to the polynomial equation F(x) = x 3 - 3x 2 + 3x - 1 = (x - 1) 3 = 0 Solution: First we apply Newton-Raphson method without any modification of the given function. It can be shown that the method does not converge for any of the starting values x 0 = 0., 0.5, 0.9, and 1.5. In fact the iterations oscillate between and But if we make the following substitution U(x) = F(x) and U(x) = F  (x) and apply the same method, i.e. x i+1 = x i - U(x i )/U(x i ) then the method converges in 24 iterations to the root x= with an error bound of 1.0E-07, and starting value of x=0.0

10 10 Systems of Nonlinear Equations Extension of the previous methods to systems of N equations with N variables Our discussion will be limited to solutions to the following system of nonlinear equations: F(x,y) = 0 G(x,y) = 0 For example, x 2 + y = 0 -exp(-x) + y = 0

11 11 Jacobi Iteration Method Jacobi method is an extension of the fixed-point iteration method to systems of equations The equations F(x,y) = 0 G(x,y) = 0 need to be transformed into x = f(x,y) y = g(x,y) Actual iteration is similar to the case of one equation with one variable x i+1 = f(x i,y i ) y i+1 = g(x i,y i )

12 12 Jacobi Iteration Method Convergence criteria - in the vicinity of the root (x r, y r ),

13 13 Example E2.5.1a

14 14 Matlab for Jacobi Method %Jacobi Iteration Method x0=0.0; y0=0.0 E=1.0E-4; % %---writing out headers to the file 'jacobimethod.dat' % fid=fopen('jacobi.dat','w'); fprintf(fid,'Roots of Equations x-5+exp(-xy)=0 \n\n') fprintf(fid,'Roots of Equations y-1+exp(-0.5x)cos(xy)=0 \n\n') fprintf(fid,'Using Jacobi Method \n') fprintf(fid,'iter x y ErrorX ErrorY \n'); fprintf(fid,' \n'); % %---entering the loop to determine the root %

15 15 Matlab for Jacobi Method (Cont’d) for i=1:100 x1=5-exp(-x0*y0); y1=1-exp(-0.5*x0)*cos(x0*y0); errorx=abs(x1-x0); errory=abs(y1-y0); %---writing out results to the file 'jacobi method.dat' % fprintf(fid,'%4.1f %7.4f %7.4f %7.4f %7.4f \n',i,x1,y1,errorx,errory); % if abs(x1-x0)-->

Similar presentations


Ads by Google