- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python – scipy.linalg.sqrtm
The sqrtm() function of scipy.linalg package can be used to find the square root of an input matrix.
Syntax
scipy.linalg.sqrtm(x)
Example 1
Let us consider the following example −
# Importing the required libraries from scipy from scipy import linalg import numpy as np # Define the input array x = np.array([[14 , 2] , [89 , 33]]) print("Input array:
", x) # Calculate the square root r = linalg.sqrtm(x) # Display the square root print("Square Root of x:
", r)
Output
It will generate the following output −
Input array: [[14 2] [89 33]] Square Root of x: [[3.43430132 0.22262855] [9.90697038 5.54927253]]
Example 2
Let us take another example −
# Importing the required libraries from scipy from scipy import linalg import numpy as np # Define the input array x = np.array([[25 , 8] , [66 , 54]]) print("Input array:
", x) # Calculate the square root m = linalg.sqrtm(x, disp=False) # Display the square root print("Square Root of x:
", m)
Output
The above program will generate the following output −
Input array: [[25 8] [66 54]] Square Root of x: (array([[4.59645076, 0.68513573], [5.65236974, 7.08006776]]), 4.668211715240082e-30)
- Related Articles
- How do I install Python SciPy?
- What are various sub-packages in Python SciPy library?
- How to solve triangular matrix equations using Python SciPy?
- How can discrete Fourier transform be performed in SciPy Python?
- How to solve a circulant matrix equation using Python SciPy?
- Explain how Nelder-Mead algorithm can be implemented using SciPy Python?
- What is the use of scipy.interpolate.interp1d class of SciPy python library?
- How to solve Hermitian positive-banded matrix equation using Python SciPy?
- Calculating Euclidean distance using SciPy
- Calculating the Manhattan distance using SciPy
- Calculating the Minkowski distance using SciPy
- Calculating the Hamming distance using SciPy
- What is SciPy in Python? Explain how it can be installed, and its applications?
- How can SciPy be used to calculate the inverse of a matrix in Python?
- How can SciPy be used to calculate the permutations and combination values in Python?
- What is interpolation and how can we implement it in the SciPy Python library?

Advertisements