Consider the system of linear algebraic equations, in which the coefficients and
ID: 3865168 • Letter: C
Question
Consider the system of linear algebraic equations, in which the coefficients and the constants are known to the number of significant digits shown.
4.000y - 5.000z = -8.000
3.000x - 6.000y - 2.000z = -23.00
5.000x - 1.000y = 2.000
Write and execute VBA code to solve the system of equations with the Gauss-Seidel algorithm. Let the solution be considered to have converged when consecutive estimates for all three variables differ by less than l0.00001% l.
Consider the system of linear algebraic equations, in which the coefficients and the constants are known to the number of significant digits shown.
4.000y - 5.000z = -8.000
3.000x - 6.000y - 2.000z = -23.00
5.000x - 1.000y = 2.000
Write and execute VBA code to solve the system of equations with the Gauss-Seidel algorithm. Let the solution be considered to have converged when consecutive estimates for all three variables differ by less than l0.00001% l.
Explanation / Answer
VBA code
4.000y - 5.000z = -8.000
3.000x - 6.000y - 2.000z = -23.00
5.000x - 1.000y = 2.000
simple matrix formula A*x = B
A = [ 0 , 4 , - 5 ; 3 , - 6 , -2 ; 5 , -1 , 0 ]
B = [ - 8, -23, 2 ]
you solve this equation, you'll find x = 1, y = 3, z = 4 ; in terms of the matric.
So, C = [ 1 ; 3 ; 4 ]
Now with the help of Excel's worksheets alongside its MMULT and MINVERSE functions makes this easy. My problem is I'm needing to do this calculation inside a VBA function.
A(1, 1, 0 ) = -6
A(1, 0 ,1) = -2
A(0 , 1 , 1 ) = 5
A( 1 , 1 , 1 ) = -1
B(0 , 0 , 0) = -8
B(0 , 1 , 0) = -23
B(1, 1, 1 ) = 2
Gauss-Seidel algorithm
4.000y - 5.000z = -8.000
3.000x - 6.000y - 2.000z = -23.00
5.000x - 1.000y = 2.000
To compare our results from the two methods, we again choose x(0) = (0, 0, 0). We then find x(1) = (x1(1), x2(1), x3(1)) by solving
0 - 0 = -8.000
3.000x - 6.000y - 0z = -23.00
5.000x - 1.000y = 2.000
In this we will use eign value and eigh vetor mathode;
X = [ k1 , k2 , k3 ] ;
Now put the values accordingly