Introduction to Linear Algebra & Multivariate Calculus

1.1 Why Multivariate Calculus in Machine Learning?

Multivariate calculus is fundamental to machine learning because:

  • Most ML models have multiple parameters (high-dimensional spaces)
  • Optimization requires understanding how functions change in multiple directions
  • Neural networks rely heavily on gradient-based learning
  • Concepts like gradients, Jacobians, and Hessians appear everywhere in ML

1.2 Scalars, Vectors, Matrices, and Tensors

  • Scalar: Single number (0-dimensional)
  • Vector: 1D array of numbers (magnitude and direction)
  • Matrix: 2D array of numbers (linear transformations)
  • Tensor: Generalized n-dimensional array

Interactive Example: Vector Visualization

Vector 1

Vector 2

View Code
import numpy as np import matplotlib.pyplot as plt # Define vectors v1 = np.array([2, 3]) v2 = np.array([-1, 2]) # Plot plt.figure(figsize=(6,6)) plt.quiver(0, 0, v1[0], v1[1], angles='xy', scale_units='xy', scale=1, color='r', label='Vector v1') plt.quiver(0, 0, v2[0], v2[1], angles='xy', scale_units='xy', scale=1, color='b', label='Vector v2') plt.xlim(-3, 3) plt.ylim(-3, 3) plt.grid() plt.legend() plt.title("Vector Visualization") plt.show()