Please note, this is a STATIC archive of website www.javatpoint.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
Javatpoint Logo
Javatpoint Logo

SciPy Linear Algebra

SciPy is built upon the ATLAS LAPACK and BLAS library, and it provides very fast linear algebra capabilities. Linear algebra routine accepts two-dimension array object and output is also given as a two-dimension array. If we want more speed in computation, then we have to dig deep in this scenario.

A linear algebra problem can be solved by typing the following scipy function:

Linear Equation

The linalg.solve is used to solve the linear equation a*x + b*y = Z, for the unknown x, y values.

x + 3y +10z = 10
2x + 12y + 7z = 18
5x + 8y + 8z = 30

Here we will solve above linear equation by using the linear.solve command for the faster calculation.

Output:

[[4.55393586]
 [0.51311953]
 [0.39067055]]

 Checking results, Vectors must be zeros 
[[0.]
 [0.]
 [0.]]

In the above program, we have declared a and b as variable where a stored coefficients of equation and b stored the right-hand-side value. Variable x stored the evaluated solution.

Finding the determinants

The determinant of the square matrix is found by using the linalg.det() function. The determinate A is often denoted as |A| in the linear algebra. It accepts a matrix and returns a scalar value.

Let's consider the following example:

Output:

-52

Eigenvalues and Eigenvectors

Finding eigenvalues and eigenvector problems are the most common problem in linear algebra. We can find the Eigenvalues (?) and the corresponding Eigenvectors (v) of a square matrix (A) by linalg.eig() function. Consider the following example:

Av = λv

Output:

[-0.37228132+0.j  5.37228132+0.j]
[[-0.82456484 -0.41597356]
 [ 0.56576746 -0.90937671]]

SciPy svd

The svd is stands for single value decomposition. The unique value decomposition of a matrix A is the factorization of A into the product of three matrices A = UDVT, where the columns of U and V are orthonormal, and the matrix D is diagonal with real positive entries.


Next TopicSciPy Ndimage





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA