Skip to content

A hands-on learning repository for understanding linear algebra concepts through Python and NumPy.

Notifications You must be signed in to change notification settings

MohammedADev/linear-algebra

Repository files navigation

Linear Algebra from Scratch

A hands-on learning repository for understanding linear algebra concepts through Python and NumPy.

Overview

This repository contains a series of lessons that build your understanding of linear algebra from the ground up. Each lesson includes:

  • Python code demonstrating concepts with NumPy
  • Comprehensive notes explaining the theory and intuition
  • Practical examples to reinforce understanding

Prerequisites

  • Python 3.x
  • NumPy

Install dependencies:

pip install numpy

Lessons

Lesson 00: Python Basics

Introduction to Python fundamentals needed for the course.

Lesson 01: Vectors

  • What vectors are (direction and size)
  • Vector representation
  • Vector addition concept

Lesson 02: Vector Operations

  • Vector addition with NumPy
  • Vector scaling (multiplying by scalars)
  • Understanding direction and magnitude

Lesson 03: Vector Length (Norm)

  • Calculating vector length using Pythagorean theorem
  • Using np.linalg.norm()
  • Understanding magnitude

Lesson 04: Distance Between Points

  • Finding distance between two points
  • Vector subtraction for distance calculation
  • Understanding B - A as a vector

Lesson 05: Dot Product

  • Dot product calculation
  • Geometric meaning: alignment vs distance
  • Perpendicular, same direction, and opposite direction vectors

Lesson 06: Angle Between Vectors

  • Cosine formula for angles
  • Normalizing vectors by dividing by lengths
  • Key cosine values (0°, 90°, 180°)
  • Understanding alignment and cosine relationships

Structure

Each lesson directory contains:

  • *.py - Python implementation files
  • notes.md - Detailed explanations and concepts

Key Concepts

  • Vectors represent direction and size, not just coordinates
  • Dot product measures alignment, not distance
  • Cosine removes vector length to measure only direction
  • cos(θ) = 0 means perpendicular (90° angle)

Getting Started

  1. Clone this repository
  2. Navigate to a lesson directory
  3. Read the notes.md file for theory
  4. Run the Python files to see concepts in action
  5. Experiment with the code to deepen understanding

Learning Path

Follow the lessons in order (00 → 01 → 02 → ...) as each builds upon previous concepts. The progression takes you from basic vector understanding to advanced operations like calculating angles between vectors.

Notes

  • All mathematical formulas use LaTeX notation for proper rendering
  • Code examples use NumPy for efficient vector operations
  • Concepts are explained both mathematically and intuitively

About

A hands-on learning repository for understanding linear algebra concepts through Python and NumPy.

Topics

Resources

Stars

Watchers

Forks

Languages