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

np.linalg.solve() से Equations हल करना

solve linear equations के एक system में unknown values ढूंढता है।

In this page:

  1. np.linalg.solve()
Syntax
python
x = np.linalg.solve(A, b)

np.linalg.solve()

np.linalg.solve(A, b) एक square, non-singular A के लिए x return करता है ऐसे कि A x = b। यह खुद inverse compute करने से ज़्यादा stable और faster है। A की हर row एक equation है और हर column एक unknown।

Note: np.allclose(A @ x, b) से अपना answer check करें।

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

python
import numpy as np

# 2x + y = 5  and  x + 3y = 10
A = np.array([[2, 1], [1, 3]])
b = np.array([5, 10])
x = np.linalg.solve(A, b)
print(x)
print(np.allclose(A @ x, b))

# Output:
# [1. 3.]
# 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. solve की बजाय inv(A) @ b इस्तेमाल करना
  2. एक singular matrix pass करना
  3. equation layout गलत पाना
चैप्टर सारांश
  • solve(A, b), A x = b solve करता है
  • A square और non-singular होना चाहिए
  • Inverting से ज़्यादा stable
  • A @ x से verify करें
🔒

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.