Numerical Methods - Chap2
Numerical Methods - Chap2
Numerical Methods
Code Entitled Semester Crédits Course Exercise Lab Total
Numerical
LS4MENU 4 3 12 15 18 45
Methods
• b) Iterative Method: leads to the solution through a series of operations for the
approximate solution. The number of iterations depends on how close the solution to
the exact solution, but it is difficult to predict since it depends on the structure of the
matrix A.
Direct methods : Cramer’s Rule
Known quantities are : A and b, Unknown: X?
A *X =b
Note how we name the elements in A , X and b
Forms of vector X
X = [ x1, or X = [x,
x2, y,
x3, z]
:
xn]
Example on AX=b
• Extract A and b in following example:
Solve using Cramer’s
Cramer’s method in brief
Ai = is the matrix created by
replacing ith column by vector b
A1
A2
A3
Solution in Cramer
x1
x2
x3
Example 1 on Cramer’s rule
• Solve by Cramer’s rule the system of equations:
4x – y + z = 7
4x – 8y + z = -21
-2x + y + 5z = 15
Solution:
é 4 éx ù é7 ù
-1 1 ù ê ú
ê ú ê ú
A=ê 4 -8 1 ú X = ê yú b = ê-21ú
ê -2 5 ú êz ú ê15 ú
ë
1
û ë û ë û
é 7 -1 1 ù
ê ú
Ax = ê -21 -8 1 ú
ê 15 1 5 ú
ë û
é 4 7 1 ù
ê ú
Ay = ê 4 -21 1 ú
ê -2 15 5 ú
ë û
é 4 -1 7 ù
ê ú
Az = ê 4 -8 -21 ú
ê -2 1 15 ú
ë û
7 -1 1
-21 -8 1
det( Ax) | Ax | | A1 | 15 1 5
x= = = = =2 =-308/-154
det( A) | A| | A| 4 -1 1
4 -8 1
-2 1 5
4 7 1
4 -21 1
det( Ay) | Ay | | A2 | -2 15 5
=-616/-154
y= = = = =4
det( A) | A| | A| 4 -1 1
4 -8 1
-2 1 5
4 -1 7
4 -8 -21
det( Az) | Az | | A3 | -2 1 15
z= = = = =3 =-462/-154
det( A) | A| | A| 4 -1 1
4 -8 1
-2 1 5
Calculate the determinant of 4 x 4 matrix A
Number of calculations for 4 x 4 matrix done for 5 determinants is (42 - 1)*4! = 360
While it was For 3 x 3 matrix (32 - 1)*3! = 48
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
•A
38
•a
39
•a
40
•c
41
•c
42
•c
43
•c
44
•c
45
•c
46
•c
47
Gauss Seidel
• By Gauss Seidel iterative Method, we calculate:
• x1 from y0 and z0
• y1 from x1 and z0
• z1 from x1 and y1
• Of course
• x2 from y1 and z1 ……
• Gauss Seidel converges Faster than Gauss Jacobi Method.
48
Homework
• Solve the following system using four methods
A) Cramer’s
B) Gauss Jordan
C) Method of Jacobi : x0=0, y0=0,z0=0 error = 0.05
D) Gauss Seidel: x0=0, y0=0,z0=0 error = 0.05
4X - y + 2z = 5
x - 3y + z = 6
2x + y -5 z = -1
49
C)
50
51
52
53
54
55