Skip to content
Learn Netverks

Lesson

Step 19/36 53% through track

linalg-basics

Linear algebra basics

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

This lesson

This lesson teaches Linear algebra basics: NumPy ndarray operations, vectorization, and numerical patterns used across the Python scientific stack.

ML feature matrices and weights are ndarray algebra—shape errors explode in training loops.

You will apply Linear algebra basics in contexts like: Scientific computing, optimization, and simulation code atop NumPy.

Read the narrative, run `import numpy as np` snippets in the playground (install NumPy with pip if the runner lacks it), tweak shapes and dtypes, and complete MCQs.

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

The np.linalg submodule covers determinants, inverses, eigenvalues, norms, and solving linear systems—foundational for ML and physics simulations.

Common functions

  • np.linalg.norm(v) — vector/matrix norm
  • np.linalg.det(M) — determinant (square matrices)
  • np.linalg.inv(M) — matrix inverse
  • np.linalg.solve(A, b) — solve Ax = b
  • np.linalg.eig(M) — eigenvalues and eigenvectors

Solve linear system

import numpy as np
A = np.array([[3, 1], [1, 2]])
b = np.array([9, 8])
x = np.linalg.solve(A, b)
print(x)

Numerical stability

Prefer solve over computing inverse explicitly. Ill-conditioned matrices need specialized routines in SciPy.

Important interview questions and answers

  1. Q: When is inverse ill-advised?
    A: Large, sparse, or near-singular matrices—inverse is slow and unstable.
  2. Q: norm default?
    A: Frobenius norm for matrices; L2 for vectors unless ord specified.

Self-check

  1. Solve 2×2 system Ax=b with given A and b.
  2. What function returns eigenvalues?

Pitfall: Prefer solve over computing matrix inverse.

Interview prep

solve vs inv?

solve Ax=b directly—more stable than inverse.

det zero?

Singular matrix—no unique inverse.

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

  • np.linalg.solve?
  • When inv dangerous?

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