Solution of a system of nonlinear equations using Newton’s method.
The equations of the catenary curve and the ellipse, which are shown in the figure, are given by:
Use Newton’s method to determine the point of intersection of the curves that resides in the first quadrant of the coordinate system.
Equations (3.49) and (3.50) are a system of two nonlinear equations. The points of intersection are given by the solution of the system. The solution with Newton’s method is obtained by using Eqs. (3.43) and (3.44). In the present problem, the partial derivatives in the equations are given by:
\frac{\partial f_{1}}{\partial x}|_{x_1,y_1} \Delta x + \frac{\partial f_{1}}{\partial y}|_{x_1,y_1} \Delta y = – f_1(x_1,y_1) (3.43)
\frac{\partial f_{2}}{\partial x}|_{x_1,y_1} \Delta x + \frac{\partial f_{2}}{\partial y}|_{x_1,y_1} \Delta y = – f_2(x_1,y_1) (3.44)
\frac{\partial f_{1}}{\partial x}=-\frac{1}{4}\left(e^{x / 2}-e^{(-x) / 2}\right) \quad \text { and } \quad \frac{\partial f_{1}}{\partial y}=1 (3.51)
\frac{\partial f_{2}}{\partial x}=18 x \text { and } \frac{\partial f_{2}}{\partial y}=50 y (3.52)
The Jacobian is given by:
\left.J\left(f_{1}, f_{2}\right)=\operatorname{det} \left[\begin{array}{ll}\frac{\partial f_{1}}{\partial x} & \frac{\partial f_{1}}{\partial y} \\\frac{\partial f_{2}}{\partial x} & \frac{\partial f_{2}}{\partial y}\end{array}\right]\right.=\operatorname{det}\left[\begin{array}{cc} -\frac{1}{4}\left(e^{x / 2}-e^{(-x) / 2}\right) & 1 \\ 18 x & 50 y \end{array}\right]=-\frac{1}{4}\left(e^{x / 2}-e^{(-x) / 2}\right) 50 y-18 x (3.53)
Substituting Eqs. (3.51)-(3.53) in Eqs. (3.45) and (3.46) gives the solution for \Delta x and \Delta y.
\Delta x = \frac{ – f_1(x_1,y_1) \frac{\partial f_{2}}{\partial y}|_{x_1,y_1} + f_2(x_1,y_1) \frac{\partial f_{1}}{\partial y}|_{x_1,y_1}}{J(f_1(x_1,y_1),f_2(x_1,y_1))} (3.45)
\Delta y = \frac{ – f_2(x_1,y_1) \frac{\partial f_{1} (x_1,y_1)}{\partial x}|_{x_1,y_1} + f_1(x_1,y_1) \frac{\partial f_{2}}{\partial x}|_{x_1,y}}{J(f_1(x_1,y_1),f_2(x_1,y_1))} (3.46)
The problem is solved in the MATLAB program that is listed below. The order of operations in the program is:
EstimatedRelativeError = \left| \frac{x_{NS}^{(n)} – x_{NS}^{(n – 1)}}{x_{NS}^{(n – 1)}}\right| (3.9)
The program also displays the solution and the error at each iteration.
% Solution of Chapter 3 Example 5
F1=@ (x,y) y - 0.5*(exp(x/2) + exp(-x/2));
F2 = @ (x,y) 9*x^2 + 25*y^2 - 225;
Flx =@ (x) -(exp(x/2) - exp(-x/2))/4;
F2x = @ (x) lB*x;
F2y = @ (y) 50*y;
Jaccb = @ (x,y) -(exp(x/2) - exp(-x/2))/4*50*y - lB*x;
xi = 2 .5; yi = 2; Err = 0.001;
for i = 1:5
Jae= Jacob(xi,yi);
Delx = (-Fl(xi,yi)*F2y(yi) + F2(xi,yi))/Jac;
Dely = (-F2(xi,yi)*Flx(xi) + Fl(xi,yi)*F2x(xi))/Jac;
xipl = xi + Delx;
yipl = yi + Dely;
Errx = abs((xipl - xi)/xi);
Erry = abs((yipl - yi)/yi);
fprintf('i =%2.0f x = %-7 .4f y = %-7 .4f Error in x = %-7 .4f Error in y = %-7.4£\n',i ,xipl f yipl ,Errx ,Erry)
if Errx < Err & Erry < Err
break
else
xi = xipl; yi = yipl;
end
end
When the program is executed, the display in the Command Window is:
i = 1 x= 3.1388 y = 2.4001 Error in x = 0.25551 Error in y = 0.20003
i = 2 x= 3.0339 y = 2.3855 Error in x = 0.03340 Error in y = 0.00607
i = 3 x= 3.0312 y = 2.3859 Error in x = 0.00091 Error in y = 0.00016
These results show that the values converge quickly to the solution.