Question

Consider the system of linear algebraic equations, in which the coefficients and the constants are known...

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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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

Add a comment
Know the answer?
Add Answer to:
Consider the system of linear algebraic equations, in which the coefficients and the constants are known...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT