Documentation

Moser.Worm.Basic

Worms #

This file defines worms as piecewise linear paths of unit length.

def Moser.sqrtApprox (s epsilon : ) (fuel : := 100) :

Approximate sqrt(s) using Newton's method (Babylonian method). Given s ≥ 0 and epsilon > 0, returns a rational r such that |r - sqrt(s)| < epsilon

Equations
Instances For
    @[irreducible]
    def Moser.sqrtApprox.newton (s epsilon x : ) (n : ) :

    One step of the Newton iteration on x, recursing up to n more times.

    Equations
    Instances For
      def Moser.distanceApprox (p q : RationalPoint) (epsilon : ) :

      Approximate the Euclidean distance between two points to within epsilon. Returns a rational d such that |d - dist(p,q)| < epsilon

      Equations
      Instances For
        def Moser.totalLengthApprox (vertices : List RationalPoint) (epsilon : ) :

        Compute an approximate total length of a path given by vertices

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          structure Moser.Worm :

          A worm is a piecewise linear path (at least 2 vertices)

          Instances For

            Scale a point by a rational factor

            Equations
            Instances For
              def Moser.Worm.scale (w : Worm) (s : ) :

              Scale all vertices of a worm by a factor

              Equations
              Instances For
                def Moser.Worm.lengthApprox (w : Worm) (epsilon : ) :

                Get the approximate total length of the worm

                Equations
                Instances For
                  def Moser.Worm.scaleToUnit (w : Worm) (epsilon : ) :

                  Scale a worm to have approximately unit length. Returns the scaled worm. The scaling factor is 1/length.

                  Equations
                  Instances For

                    Convert worm vertices to a convex polygon

                    Equations
                    Instances For

                      Get the convex hull as a ConvexPolygon

                      Equations
                      Instances For
                        structure Moser.UnitWorm :

                        A unit worm is a worm with total length approximately 1

                        • worm : Worm

                          The underlying worm

                        • unitLength (epsilon : ) : epsilon > 0|self.worm.lengthApprox epsilon - 1| < epsilon

                          The total length is approximately 1 (converges to 1 as epsilon → 0)

                        Instances For

                          Get the vertices of a unit worm

                          Equations
                          Instances For

                            Convert to a convex polygon

                            Equations
                            Instances For
                              def Moser.Worm.toUnitWorm (w : Worm) (epsilon : ) :

                              Convert a worm to a unit worm by scaling to unit length. The epsilon parameter controls the precision of the length computation.

                              Equations
                              Instances For