Linear Equation Solvers Assignment Answers
Your question:
1. Write a program that will solve for the unknown of a system of linear equation using cholesky’s method. The program should be able solve different system of linear equation from a single interface.
2. Write a program that will solve for the unknown of a system of linear equation using gauss Jordan method. The program should be able to solve different system of linear equation from a single interface.
Assignment Help Answers with Step-by-Step Explanation:
#include <vector>
#include <cmath>
for (int j = 0; j <= i; j++) {
double sum = 0.0;
L[i][j] = sqrt(A[i][i] - sum);
} else {
}
}
int n = A.size();
std::vector<std::vector<double>> L(n, std::vector<double>(n, 0.0));
for (int i = 0; i < n; i++) {
double sum = 0.0;
}
// Backward substitution
}
x[i] = (y[i] - sum) / L[i][i];
// Define your system of linear equations here.
std::vector<std::vector<double>> A = {{4, 2, 2},
std::cout << "Solution: ";
for (double x : solution) {
}
2. Gauss-Jordan Method
int n = A.size();
for (int i = 0; i < n; i++) {
A[i][j] /= pivot;
}
double factor = A[k][i];
for (int j = i; j < n; j++) {
}
}
for (int i = 0; i < A.size(); i++) {
augmentedMatrix[i].push_back(b[i]);
}
int main() {
std::vector<double> b = {8, 14, 4};
std::vector<double> solution = solveGaussJordan(A, b);
std::cout << std::endl;
return 0;