Consider the system of linear algebraic equations, in which the
coefficients and the constants are known to the number of
significant digits shown. 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. |
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.
Dim A(0 To 2, 0 To 2) As Single Dim B(0 To 0, 0 To 2) As Single Dim X(0 To 0, 0 To 2) As Single
A(0, 0 ,0 ) = 0 A(1, 0 ,0 ) = 4 A(0, 1 ,0) = -5 A(0, 0, 1) = 3
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
Consider the system of linear algebraic equations, in which the coefficients and the constants are known...
Tutorial 4. Linear systems of algebraic equations 2 October, 4-5 pm in FN2 (Q1) Consider this linear system of equations a. 1 p -2 0 0 0 1 0 q 0 4 2r -2 0 -1 0 4s Order the four equations such that the system of equations can be solved efficiently by Gauss elimination b. Solve the system by Gauss elimination (Q2) -1] 6 Given the linear system of equations A5 with [A| solve for i 10 and by...
1) Consider the system of linear algebraic equations Ax = B where | 1 1/2 1/31 1/2 1/3 1/4 11/3 1/4 1/5 a) Find x, A" and det(A) using Gauss-Jordan elimination without pivoting. b) Using the result of part (a), find the condition number of A based on the Euclidean (Frobenius) norm. How many digits of precision do you suspect are lost in the solution x due to ill-conditioning?
Q1 The linear system Ax = b is given by: x1−x2 + 4x3 = 7 4x1 + 2x2 –x3= 18, x1 + 3x2+ x3 = 16, has the solution x=(3, 4,2)T. Using the initial guess x (0)=(1, 1,1)T Solve the above system as is using: Gauss-Seidel method. If the error increases, what does that mean and what should you do? (see b below) Condition the system so that convergence is secured and solve using the Gauss-Siedel method. Q2: Find a system...
Consider the following system of linear algebraic equations: 7.121 + 2.9.02 + 2.2.03 + 3.3x4 = 4.2 4.121 +3.422 + 5.0.03 + 1.2x4 = 1.9 4.721 +3.822 + 2.9.03 + 1.4x4 = 1.1 2.0x1 + 2.5.2 + 2.8.03 + 4.7:24 = 1.1 Perform the first step in Gauss elimination to eliminate 21 from the second, third and forth equations, converting the system to the form given below. Fill in the blank spaces. Round up your answers to 4 decimals. 7.121...
Consider the following system of linear algebraic equations: 6.3x1 + 3.4x2 + 1.8x3 + 4.3x4 3.8 1.5x1 + 3.0x2 + 1.3x3 + 3.3x4 2.9 2.8x1 + 1.2x2 + 3.6x3 + 2.6x4 4.0 4.3x1 + 2.0.x2 + 3.0x3 + 2.6x4 4.3 Perform the first step in Gauss elimination to eliminate xi from the second, third and forth equations, converting the system to the form given below. Fill in the blank spaces. Round up your answers to 4 decimals. 6.3x1 + 3.4x2...
Consider the following system of linear algebraic equations: 5.501 +3.222 +2.703 +1.104 = 5.0 4.501 +3.322 +4.9.13 +2.4.24 = 3.2 3.1.11 +1.4.22 +2.823 +3.0x4=2.0 2.801 +4.332 + 1.73 +1.624 = 3.3 Perform the first step in Gauss elimination to eliminate 21 from the second third and forth equations, converting the system to the form given below. Fill in the blank spaces. Round up your answers to 4 decimals. 5.5.21 +3.222 +2.723 + 1.1.4 = 5.0 12 + |a3 + 24...
The pscudocode shown below solves a system of n linear algebraic equations using Gauss-Jordan 125] elimination. DOFOR -1,n DOPOR 1 = k + 1,n + 1 END DO ae 1 DOFOR 1 = 1, n k THEN IF i DOFOR j- k+1,n+ 1 ENDDO END IF END DO END DO DOFOR m-1,n END DO Write a Matlab function program GaussJordan(A,n) which implements this algorithm and a) returns the solution. Here A is the augmented matrix consisting of the coefficient matrix...