← Back to NumPy Course | Chapter 7: Linear Algebra | Lesson 2 of 6

np.linalg.inv() से Inverse Matrix

एक matrix का inverse इसे undo करता है: एक matrix को इसके inverse से multiply करना identity matrix देता है।

In this page:

  1. np.linalg.inv()
Syntax
python
inverse = np.linalg.inv(matrix)

np.linalg.inv()

np.linalg.inv एक square, non-singular matrix का inverse return करता है। A को इसके inverse से multiply करना rounding error तक identity देता है। एक singular matrix LinAlgError raise करता है।

Note: Ax = b solve करने के लिए, inv से np.linalg.solve prefer करें; यह faster और ज़्यादा accurate है।

उदाहरण: np.linalg.inv()

python
import numpy as np

A = np.array([[4.0, 7.0], [2.0, 6.0]])
Ainv = np.linalg.inv(A)
print(Ainv.round(2))
print(np.allclose(A @ Ainv, np.eye(2)))

# Output:
# [[ 0.6 -0.7]
#  [-0.2  0.4]]
# True
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. एक singular matrix invert करना
  2. बिना allclose के identity से equality test करना
  3. जब solve बेहतर हो inv इस्तेमाल करना
चैप्टर सारांश
  • inv को एक square non-singular matrix चाहिए
  • A @ inv(A) identity है
  • Checks के लिए allclose इस्तेमाल करें
  • Linear systems के लिए solve prefer करें
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.