A beginner-friendly collection of Jupyter notebooks covering the essentials of linear algebra with clear NumPy code and visualizations. Ideal for students and self-learners.
- Vectors: Addition, scalar multiplication, magnitude
- Basis Vectors: i-hat, j-hat, linear combinations
- Linear Transformations: Rotation, shear, and their effects
- Matrix Multiplication: Composition of transformations
- Dot Product: Projection, alignment, angle between vectors
- Determinant: Area scaling, singularity, flipping
- Eigenvalues & Eigenvectors: Invariant directions and scaling
- Matrix Inverse: How to compute and visualize the inverse
- Rank of a Matrix: Linear independence and dimension
- Cross Product (3D): Perpendicular vector in 3D space
Everything you've learned maps directly to the systems you're building. Here's the full picture.
| 3B1B Concept | NumPy Tool | Where in AI |
|---|---|---|
| Vectors | np.array([...]) |
Word embeddings, query vectors, document chunks in RAG |
| Magnitude | np.linalg.norm() |
Normalizing embeddings before cosine similarity |
| Linear Transformation | matrix @ vector |
Every neural network layer: output = W @ input + b |
| Dot Product | np.dot() / @ |
Attention scores in transformers, cosine similarity in RAG retrieval |
| Matrix Multiplication | A @ B |
Batched forward passes, QKV projections in attention |
| Determinant | np.linalg.det() |
Checking if weight matrices are well-conditioned |
| Eigenvectors | np.linalg.eig() |
PCA for visualizing embedding spaces, SVD in recommendation systems |
linalg_notebook_simple.ipynb: Step-by-step notebook with explanations and plotsrequirements.txt: List of required Python packages
- Clone the repository
git clone https://github.com/your-username/linear-algebra-essentials.git cd linear-algebra-essentials - Set up your environment
- (Recommended) Create a virtual environment:
python3 -m venv venv source venv/bin/activate - Install dependencies:
pip install -r requirements.txt
- (Recommended) Create a virtual environment:
- Launch Jupyter Notebook
jupyter notebook
- Open
linalg_notebook_simple.ipynband run the cells
- Each section introduces a new concept with code and a plot.
- Run cells in order for best results.
- Experiment by changing values and re-running cells to deepen your understanding.
MIT License
Feel free to contribute or suggest improvements!