Documentation

Mathlib.LinearAlgebra.Matrix.Determinant.Bird

A division-free determinant algorithm #

This file defines birdDet, an implementation of an division-free algorithm for computing determinants. The algorithm runs in O(n^4) for an n-by-n matrix.

This determinant algorithm comes from:

Title: A simple division-free algorithm for computing determinants. Author: Richard S. Bird URL: https://doi.org/10.1016/j.ipl.2011.08.006

Main definitions #

Main lemmas #

The lemmas in this file are unfolding equations.

def BirdDet.get {R : Type u_1} [CommRing R] (n : ) (A : Array R) (i j : ) :
R

get n A i j returns the (i, j)th entry of the n × n matrix whose entries are stored in A in row-major order.

The function does not check the matrix index bounds.

Equations
Instances For
    @[irreducible]
    def BirdDet.sumFrom {R : Type u_1} [CommRing R] (n lo : ) (f : R) :
    R

    Sum f lo + ... + f (n - 1). Returns zero when n <= lo.

    Equations
    Instances For
      def BirdDet.iter {R : Type u_1} [CommRing R] (n : ) (A : Array R) (t : ) (F : R) :
      R

      Scalar formula for one recurrence step. #

      Bird's paper defines a matrix recursion for an n × n matrix A:

      F_0 = A
      F_{t+1} = μ(F_t) * A
      

      where μ(F_t) is obtained from F_t by replacing each diagonal entry F_t k k with the negative sum of the diagonal entries below it, setting the entries in the lower triangular part to 0, and leaving all other entries unchanged:

      μ(F_t) =
        0                                   if i >= j
        - ∑ k from i+1 to n-1, F_t k k      if i = j
        F_t i j                             if i < j
      

      If we write out the entry-wise matrix multiplication F_{t+1} i j = (μ(F_t) * A) i j we obtain:

      F_{t+1} i j =
        - (∑ k from i+1 to n-1, F_t k k) * (A i j)
        + ∑ k from i+1 to n-1, (F_t i k) * (A k j)
      
      Equations
      • One or more equations did not get rendered due to their size.
      • BirdDet.iter n A 0 F = F
      Instances For
        def BirdDet.birdDet {R : Type u_1} [CommRing R] (n : ) (A : Array R) :
        R

        birdDet n A computes the determinant of the n × n matrix whose entries are stored in A in row-major order.

        Equations
        Instances For
          theorem BirdDet.sumFrom_step {R : Type u_1} [CommRing R] (n lo : ) (f : R) (h : lo < n) :
          BirdDet.sumFrom n lo f = f lo + BirdDet.sumFrom n (lo + 1) f
          theorem BirdDet.sumFrom_stop {R : Type u_1} [CommRing R] (n lo : ) (f : R) (h : ¬lo < n) :
          theorem BirdDet.iter_zero {R : Type u_1} [CommRing R] (n : ) (A : Array R) (F : R) (i j : ) :
          BirdDet.iter n A 0 F i j = F i j
          theorem BirdDet.iter_succ {R : Type u_1} [CommRing R] (n : ) (A : Array R) (t : ) (F : R) (i j : ) :
          BirdDet.iter n A (t + 1) F i j = (-BirdDet.sumFrom n (i + 1) fun (k : ) => BirdDet.iter n A t F k k) * BirdDet.get n A i j + BirdDet.sumFrom n (i + 1) fun (k : ) => BirdDet.iter n A t F i k * BirdDet.get n A k j
          theorem BirdDet.birdDet_zero {R : Type u_1} [CommRing R] (A : Array R) :
          birdDet 0 A = 1
          theorem BirdDet.birdDet_eq {R : Type u_1} [CommRing R] (n k : ) (A : Array R) (hn : n = k + 1) :
          birdDet n A = (-1) ^ k * BirdDet.iter n A k (BirdDet.get n A) 0 0