Write a "Python" program that reads coefficients and the right-hand side vector of a linear equation system from a given file (input.txt). The last row of the "input.txt" file is the right-hand side vector of a linear equation system. The coefficients of the linear equation will be integer as shown below. 4x0 +x1= 3 2x0 +5x1 = 1 The content of "input.txt" will be: Size=2 41 25 31 (a) Print the given matrix to the "output.txt" file as shown below: The content of the "output.txt" file: +4x0 +1x1 = 3 +2x0 +5x1 = 1 (b) solve the given linear equation system using the Gauss Elimination and Jacobi methods. Print the solutions to the "output_results.txt". The content of the "output_results.txt" file should be (the 4th digit after the decimal point will be rounded): The solution of the system by Gauss Elimination: x1=0.7778 x2=-0.1111 The solution of the system by Jacobi Method: x1=0.7778 x2=-0.1111 Note : Please write your code by writing functions one for Gauss Elimination Method, one for Jacobi method, one for the

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
Write a "Python" program that reads coefficients and the right-hand side vector of a linear equation system from a given file
(input.txt). The last row of the "input.txt" file is the right-hand side vector of a linear equation system. The coefficients of the
linear equation will be integer as shown below.
4x0 +x1 = 3
2x0 +5x1 = 1
The content of "input.txt" will be:
Size=2
4 1
25
31
(a) Print the given matrix to the "output.txt" file as shown below:
The content of the "output.txt" file:
+4x0 +1x1 = 3
+2x0 +5x1 = 1
(b) solve the given linear equation system using the Gauss Elimination and Jacobi methods.
Print the solutions to the "output_results.txt".
The content of the "output_results.txt" file should be (the 4th digit after the decimal point will be rounded):
The solution of the system by Gauss Elimination:
x1=0.7778
x2=-0.1111
The solution of the system by Jacobi Method:
x1=0.7778
x2 -0.1111
Note: Please write your code by writing functions one for Gauss Elimination Method, one for Jacobi method, one for the
data input from the text file and defining the system as Ax=bi.
Transcribed Image Text:Write a "Python" program that reads coefficients and the right-hand side vector of a linear equation system from a given file (input.txt). The last row of the "input.txt" file is the right-hand side vector of a linear equation system. The coefficients of the linear equation will be integer as shown below. 4x0 +x1 = 3 2x0 +5x1 = 1 The content of "input.txt" will be: Size=2 4 1 25 31 (a) Print the given matrix to the "output.txt" file as shown below: The content of the "output.txt" file: +4x0 +1x1 = 3 +2x0 +5x1 = 1 (b) solve the given linear equation system using the Gauss Elimination and Jacobi methods. Print the solutions to the "output_results.txt". The content of the "output_results.txt" file should be (the 4th digit after the decimal point will be rounded): The solution of the system by Gauss Elimination: x1=0.7778 x2=-0.1111 The solution of the system by Jacobi Method: x1=0.7778 x2 -0.1111 Note: Please write your code by writing functions one for Gauss Elimination Method, one for Jacobi method, one for the data input from the text file and defining the system as Ax=bi.
Expert Solution
steps

Step by step

Solved in 4 steps with 6 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT