LINEAR_PROJECT
LINEAR_PROJECT
SUBMITTED BY:
of
SUBMITTED TO:
• Question 1 involves linear transformations and matrix diagonalization. The task requires
constructing the standard matrix A corresponding to a given linear operator T: R3→R3 followed by
testing whether A is diagonalizable. If it is, a matrix P is found such that P-1 AP is diagonal.
• Question 2 deepens the analysis of matrix diagonalization and matrix powers. You are given a
matrix A and a matrix P claimed to diagonalize it. The goal is to verify the diagonalization and
then compute a high power of the matrix, A20, using the property that powers of diagonal matrices
are easily calculated.
• Question 4 shifts from theory to application by requiring students to write C++ or Python code
to perform matrix diagonalization. The program should take a matrix as input (such as the one
in Question 1) and compute its eigenvalues and eigenvectors to construct the diagonal and
transformation matrices.
• Question 5 continues the computational focus with a programmatic implementation of the Gram-
Schmidt orthonormalization algorithm. The goal is to automate the manual process used in
Question 3, reinforcing the link between algorithmic thinking and mathematical procedures.
This project provides a blend of theoretical understanding and practical computation, aiming to equip
students with both conceptual clarity and problem-solving skills. It demonstrates how abstract algebraic
operations like diagonalization and orthogonalization are not only mathematically elegant but also
computationally essential in fields such as computer graphics, data science, and machine learning.
Question#1 Solution
Question#2 Solution
Question#3 Solution
C++ Implementation
Question#4:
INPUT CODE
#include <iostream>
#include <vector>
#include <cmath>
const vector<vector<double>>& B) {
int n = A.size();
return result;
}
// Function to check if two matrices are equal (within epsilon)
if (i == j) {
else {
}
}
return true;
vector<double> roots;
for (double x = -10; x <= 10; x += 0.1) {
double val = x * x * x + a * x * x + b * x + c;
found = true;
if (!found)
roots.push_back(x);
return roots;
vector<vector<double>> eigenvectors;
int n = A.size();
vector<vector<double>> B = A;
B[i][i] -= lambda;
double sum = 0;
if (pivot_col == -1)
pivot_col = col;
else
if (pivot_col != -1)
}
double norm = 0;
norm = sqrt(norm);
eigenvectors.push_back(eigenvector);
return eigenvectors;
int main() {
vector<vector<double>> A = {
{8, 3, -4},
{-3, 1, 3},
{4, 3, 0}
};
for (double val : eigenvalues) cout << val << " ";
cout << endl << endl;
vector<vector<double>> eigenvectors = findEigenvectors(A, eigenvalues);
return 0;
printMatrix(P);
cout << "Diagonal matrix (should have eigenvalues on diagonal):" << endl;
return 0;
}
CODE OUTPUT
Question#5:
INPUT CODE
#include <iostream>
#include <vector>
#include <cmath>
}
return result;
vector<double> result(v.size());
}
return result;}
// Function to subtract the projection of v onto u from v
vector<double> result(v.size());
for (size_t i = 0; i < v.size(); ++i) {
return result;
int main() {
// Original basis vectors
vector<vector<double>> basis = {
{1, 1, 1}, // u1
{-1, 1, 0}, // u2
{1, 2, 1} // u3
};
vector<vector<double>> orthonormalBasis;
// First vector: just normalize u1
orthonormalBasis.push_back(normalize(basis[0]));
orthonormalBasis.push_back(normalize(v2));
v3 = subtractProjection(v3, orthonormalBasis[1]);
orthonormalBasis.push_back(normalize(v3));
// Verify orthonormality
printVector(vec);
cout << "e" << i + 1 << "·e" << j + 1 << " = " << dp;
else {
cout << " (not orthonormal)" << endl;
return 0;
}
CODE OUTPUT
Conclusion
In this project, we learned how to work with important topics in linear algebra like matrix diagonalization,
eigenvalues, eigenvectors, and the Gram-Schmidt process. We found the standard matrix for a given
transformation, checked if it was diagonalizable, and created a matrix that diagonalizes it.
We also used the Gram-Schmidt method to turn a set of vectors into an orthonormal basis. Along with
solving the questions by hand, we wrote simple C++ programs to do the same tasks using code.
This project helped us understand both the theory and the practical use of linear algebra. It showed how
we can use programming to solve mathematical problems in a clear and simple way.
<<THE END>>