Chapter 16: Abstract Vector Spaces

What Really Is a Vector?

We’ve been thinking of vectors as:

  • Arrows in space

  • Lists of numbers

But the truth is much deeper!

The Big Reveal

Anything that can be:

  • Added together

  • Scaled by numbers

…can be treated as a “vector”!

This includes:

  • Functions

  • Polynomials

  • Matrices

  • Music signals

  • And more!

Welcome to abstract vector spaces!

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

sns.set_style('whitegrid')
plt.rcParams['figure.figsize'] = (12, 10)

1. Functions as Vectors

Functions can be added and scaled, just like arrows!

Adding Functions

\[ (f + g)(x) = f(x) + g(x) \]

Scaling Functions

\[ (cf)(x) = c \cdot f(x) \]

Example: sin(x) and cos(x) are “basis vectors” in function space!

\[ 2\sin(x) + 3\cos(x) \]

This is a linear combination!

def demonstrate_function_addition():
    """Show functions as vectors."""
    x = np.linspace(0, 2*np.pi, 100)
    
    f = np.sin(x)
    g = np.cos(x)
    
    fig, axes = plt.subplots(2, 2, figsize=(14, 10))
    
    # Addition
    ax1 = axes[0, 0]
    ax1.plot(x, f, 'b-', label='f = sin(x)', linewidth=2)
    ax1.plot(x, g, 'r-', label='g = cos(x)', linewidth=2)
    ax1.plot(x, f+g, 'g--', label='f + g', linewidth=2)
    ax1.set_title('Function Addition', fontweight='bold')
    ax1.legend()
    ax1.grid(True, alpha=0.3)
    
    # Scaling
    ax2 = axes[0, 1]
    ax2.plot(x, f, 'b-', alpha=0.5, label='f')
    ax2.plot(x, 2*f, 'b-', linewidth=2, label='2f')
    ax2.set_title('Scalar Multiplication', fontweight='bold')
    ax2.legend()
    ax2.grid(True, alpha=0.3)
    
    # Linear combination
    ax3 = axes[1, 0]
    ax3.plot(x, 2*f, 'b--', alpha=0.5, label='2·sin(x)')
    ax3.plot(x, 3*g, 'r--', alpha=0.5, label='3·cos(x)')
    ax3.plot(x, 2*f+3*g, 'purple', linewidth=2, label='2·sin(x) + 3·cos(x)')
    ax3.set_title('Linear Combination', fontweight='bold')
    ax3.legend()
    ax3.grid(True, alpha=0.3)
    
    # Basis
    ax4 = axes[1, 1]
    ax4.plot(x, f, 'b-', label='sin(x) basis', linewidth=2)
    ax4.plot(x, g, 'r-', label='cos(x) basis', linewidth=2)
    ax4.set_title('Basis Functions', fontweight='bold')
    ax4.legend()
    ax4.grid(True, alpha=0.3)
    
    plt.tight_layout()
    plt.show()
    
    print("Functions as Vectors")
    print("• Can add: f + g")
    print("• Can scale: 2f, 3g")
    print("• Linear combinations: 2f + 3g")

demonstrate_function_addition()

2. The Derivative is Linear!

The derivative is a linear transformation:

\[ \frac{d}{dx}(f + g) = \frac{df}{dx} + \frac{dg}{dx} \]
\[ \frac{d}{dx}(cf) = c\frac{df}{dx} \]

So derivatives are like “matrices” acting on function vectors!

def derivative_as_transformation():
    """Show derivative as linear transformation."""
    # For polynomials: basis {1, x, x², x³}
    # Derivative matrix
    D = np.array([
        [0, 1, 0, 0],
        [0, 0, 2, 0],
        [0, 0, 0, 3],
        [0, 0, 0, 0]
    ])
    
    print("Derivative as Matrix\n")
    print("Basis: {1, x, x², x³}\n")
    print("Derivative 'matrix' D:")
    print(D)
    
    # p(x) = 2 + 3x + x² + x³
    p = np.array([2, 3, 1, 1])
    dp = D @ p
    
    print(f"\nPolynomial p(x) = 2 + 3x + x² + x³")
    print(f"Derivative p'(x) = {dp[0]} + {dp[1]}x + {dp[2]}x² + {dp[3]}x³")
    print(f"           = 3 + 2x + 3x² ✓")

derivative_as_transformation()

Summary

The Big Picture

Vectors are not just arrows!
They are any objects that can be added and scaled.

Examples of Vector Spaces

  1. ℝⁿ: Standard space (arrows, coordinates)

  2. Functions: All continuous functions

  3. Polynomials: All polynomials of degree ≤ n

  4. Matrices: All m×n matrices

  5. Quantum states

Why Abstract?

Abstraction = Power

Proving theorems for abstract vector spaces means:

  • Results apply to all vector spaces

  • Don’t need to reprove for each case

  • Unifies different areas of mathematics

The Essence

Linear algebra is about:

  1. Vector spaces: Sets with addition and scaling

  2. Linear transformations: Structure-preserving functions

  3. Bases: Coordinate systems

  4. Dimension: Degrees of freedom

These concepts are universal patterns in mathematics!

🎉 Series Complete!

You’ve journeyed from concrete vectors to abstract spaces!

What You’ve Learned

✅ Geometric intuition for all major concepts
✅ Computational techniques
✅ Real-world applications
✅ The abstract mathematical framework

Next Steps

  • Apply to your field

  • Practice with real problems

  • Explore advanced topics (SVD, tensors)

  • Teach others!

Happy learning! 🚀