# Creating Symmetric Matrices | Linear Algebra using Python

Linear Algebra using Python | Creating symmetric Matrices: Here, we are going to learn about the creating symmetric matrices and its implementation in Python.
Submitted by Anuj Singh, on June 13, 2020

Prerequisite:

Here, we will learn how to create a symmetric matrix using a non-symmetric matrix? The following equation shows how a dot product of Matrix A and AT can result in a symmetric matrix.

S = A.AT

## Python code creating symmetric matrix

```# Linear Algebra Learning Sequence
# Creating a Symmetric Matrix

import numpy as np

M = np.array([[2,3,4], [3,45,8], [34,7,0.8], [21,31,41]])

print('A : ', M)
print('\n\nTranspose of A : ', M.T)

S = np.matmul(M,M.T)

print('\n\nSymmetric Matrix : \n', S)
```

Output:

```A :  [[ 2.   3.   4. ]
[ 3.  45.   8. ]
[34.   7.   0.8]
[21.  31.  41. ]]

Transpose of A :  [[ 2.   3.  34.  21. ]
[ 3.  45.   7.  31. ]
[ 4.   8.   0.8 41. ]]

Symmetric Matrix :
[[  29.    173.     92.2   299.  ]
[ 173.   2098.    423.4  1786.  ]
[  92.2   423.4  1205.64  963.8 ]
[ 299.   1786.    963.8  3083.  ]]
```

Preparation

What's New

Top Interview Coding Problems/Challenges!