CHE210 Tutorial4 2024
CHE210 Tutorial4 2024
Numerical Methods in
Engineering
Tutorial – 4
Newton’s Method
Ø We obtain Newton's iterative method before:
Ø However, it can only be used to solve nonlinear equations involving only a single variable.
Ø In order to use it to solve a set of nonlinear algebraic equations involving multiple variables We
know from Linear Algebra that we can take systems of equations and express those systems in the
form of matrices and vectors.
Ø We can express the nonlinear system as a matrix with a corresponding vector. Thus, the following
equation is derived:
The Jacobian Matrix
• In the vector calculation, the Jacobi matrix is the matrix containing all first-order
partial derivatives of a vector-valued function.
• Equations matrix;
• Define the matrix J(x) by .The matrix J is the derivative of the F matrix according
to its variables.
Multivariable Non-linear Equations
Problem: Find x such that F x = 0
*
( )
*
F ( x) = F ( x* ) + J ( x* )( x - x* ) Taylor Series
é ¶F1 ( x) ¶F1 ( x) ù
ê ¶x ú
¶ x
ê 1 N
ú
J ( x) = ê ú Jacobian Matrix
ê ¶FN ( x) ¶FN ( x) ú
ê ¶x1 ¶x N ú
ë û
Þ x k +1 = x k - J ( x k ) -1 F ( x k ) Iteration function
Multivariable Non-linear Equations
Computational Aspects
Iteration : x k +1 = x k - J ( x k ) -1 F ( x k )
k -1
Do not compute J ( x ) (it is not sparse).
k +1
Instead solve : k
J ( x )( x - x ) = -F (x )
k k
% Tolerance
tol = 10^-6;
err = 1;
while err>tol
xy_new = xy - J(xy(1),xy(2))\F(xy(1),xy(2));
err = abs(xy_new-xy);
xy = xy_new;
end
disp([xy,err])
% Functions
% Tolerance
% Initial guess for x and y
tol = 10^-6;
xy = [0.5; 1.5];
% Tolerance
tol = 1e-6;
err = 1;
while err>tol
x_new = x - J(x(1),x(2),x(3))\F(x(1),x(2),x(3));
err = abs(x_new - x);
x = x_new;
end
disp([x,err,F(x(1),x(2),x(3))])
Example 3
ØSolve the following nonlinear system
• Initial vector
% Tolerance
tol = 10^-6;
err = 1;
while err>tol
x_new = x - J(x(1),x(2),x(3))\F(x(1),x(2),x(3));
err = abs(x_new-x);
x = x_new;
end
disp([x,err,F(x(1),x(2),x(3))])