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.  ]]





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.