Question
Write a program that asks the user for the number of linear equations to solve (lets say n
Write a program that asks the user for the number of linear equations to solve (lets say n <=10) using the following three methods. Ask the user to first enter the number of equations and then give them the choice to enter the coefficients from the command line (by asking for each row that includes the b value) or have them enter a file name which has the augmented coefficient matrix (including the b values) in a simple text file format as seen below for an example of 3 equations :
1) the scaled partial pivoting method for Gaussian elimination.
2) Jacobi iterative method (this method will require an additional input the user has to enter, which is the desired error)
3) Gauss-Seidel method (again, the user has to enter the desired error that will be used for stopping condition).
If the iterative methods don't achieve the desired error in 50 iterations, end the iterative method and print out the x column vector for the final iteration.
E.g. the contents of a file for 3 linear equations 2x+3y-z = 4, 3x+y+2z=5, x+4z=1 will be
2 3 -1 4
3 1 2 5
1 0 4 1
The final output of your program should be the solution in the following format :
x=2
y=2
z=1
Also, please print the intermediate matrices for the Gaussian Elimination method (1)
and the values of the column vector x after each iteration for the other two methods.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started