Skip to content
Learn Netverks

Lesson

Step 19/36 53% through track

solve-linear-systems

Solve linear systems

Last reviewed Jun 1, 2026 Content v20260601
Track mode
server_script
Means
Server runner
Reading
~1 min
Level
beginner

This lesson

This lesson teaches Solve linear systems: SciPy scientific routines on NumPy arrays—statistics, optimization, linear algebra, and numerical methods.

Teams apply Solve linear systems in every serious SciPy project—skipping it leaves blind spots in analysis and reviews.

You will apply Solve linear systems in contexts like: Research code, engineering simulations, and specialized analytics.

Read the narrative, run NumPy + SciPy snippets in the playground (install scipy and numpy with pip if needed), inspect outputs and convergence, and complete MCQs.

When you can explain the previous lesson's ideas in your own words.

Solve Ax = b with linalg.solve(A, b). Prefer solve over explicit inverse—faster and more stable. For multiple right-hand sides, reuse factorizations.

Basic solve

import numpy as np
from scipy import linalg

A = np.array([[3., 1.], [1., 2.]])
b = np.array([9., 8.])
x = linalg.solve(A, b)
print('x:', x)
print('residual:', np.linalg.norm(A @ x - b))

Square vs least squares

  • Square nonsingular A → unique solution
  • Overdetermined (more rows) → lstsq least-squares fit
  • Underdetermined → infinitely many; add constraints or regularization

lu factorization reuse

lu, piv = linalg.lu_factor(A) then linalg.lu_solve((lu, piv), b) when solving many b vectors with same A.

Important interview questions and answers

  1. Q: Why not inv(A) @ b?
    A: Explicit inverse is slower and amplifies numerical errors—solve uses factorization.
  2. Q: Residual check?
    A: Compute ||Ax − b|| to verify solution quality after solve.

Self-check

  1. Write the equation form for linalg.solve.
  2. When use lstsq instead of solve?

Pitfall: Prefer solve over inv(A) @ b—faster and more stable.

Interview prep

solve vs inv?

solve uses factorization—prefer over explicit inverse.

lstsq?

Least squares when overdetermined or rank-deficient.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • solve vs inv?
  • Ill-conditioned?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump