</> APL Run Loading interactive WebAssembly workspace…

🎓 Chapter 9: Linear Algebra & Matrix Math

APL was originally created as a mathematical notation for linear algebra and array manipulation.

---

1. Matrix Multiplication with Inner Product (A +.× B)

The Inner Product operator (A f.g B) generalizes dot products.

When instantiated as +.×, it performs standard linear algebra Matrix Multiplication:

C[i, j] = sum(A[i, k] × B[k, j])

A ← 2 2 ⍴ 1 2 3 4
B ← 2 2 ⍴ 5 6 7 8
⍝ Compute matrix product A +.× B
A +.× B

---

2. Matrix Inversion & Domino Operator (⌹)

The Domino primitive (⌹) handles matrix inverses and linear system solvers:

  • Monadic Matrix Inverse (⌹ M): Calculates the inverse matrix M⁻¹.
  • Dyadic Linear Solver (B ⌹ A): Solves the system of equations A · x = B.

Example:

Solve the simultaneous equations:

2x + y = 5

x + 3y = 10

A ← 2 2 ⍴ 2 1 1 3
B ← 5 10
⍝ Solve for vector x = [x, y]
B ⌹ A

← Chapter 8: Sorting (⍋ ⍒), Grouping (⌸) & Data Manipulation Chapter 10: Conway's Game of Life & Fractals in APL →