Home >Backend Development >C++ >Can a square matrix be expressed as the sum of a symmetric matrix and an antisymmetric matrix?
Symmetric matrix - A matrix whose transpose is equal to the matrix itself. Then it is called symmetric matrix.
Antisymmetric Matrix - Its transpose is equal to the negative value of the matrix, then it is called antisymmetric matrix.
The sum of a symmetric matrix and an antisymmetric matrix is a square matrix. To find the sum of these matrices we have the following formula.
Suppose A is a square matrix. Then,
A = (½)*(A A`) (½ )*(A - A`),
A` is the transpose of the matrix.
(½ )(A A`) is a symmetric matrix.
(½ )(A - A`) is an antisymmetric matrix.
#include <bits/stdc++.h> using namespace std; #define N 3 void printMatrix(float mat[N][N]) { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) cout << mat[i][j] << " "; cout << endl; } } int main() { float mat[N][N] = { { 2, -2, -4 }, { -1, 3, 4 }, { 1, -2, -3 } }; float tr[N][N]; for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) tr[i][j] = mat[j][i]; float symm[N][N], skewsymm[N][N]; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { symm[i][j] = (mat[i][j] + tr[i][j]) / 2; skewsymm[i][j] = (mat[i][j] - tr[i][j]) / 2; } } cout << "Symmetric matrix-" << endl; printMatrix(symm); cout << "Skew Symmetric matrix-" << endl; printMatrix(skewsymm); return 0; }
Symmetric matrix - 2 -1.5 -1.5 -1.5 3 1 -1.5 1 -3 Skew Symmetric matrix - 0 -0.5 -2.5 0.5 0 3 2.5 -3 0
The above is the detailed content of Can a square matrix be expressed as the sum of a symmetric matrix and an antisymmetric matrix?. For more information, please follow other related articles on the PHP Chinese website!