Git Product home page Git Product logo

numeric-construction's Introduction

numeric-construction

Constructing Number Systems from First Principles

In the beginning, there was zero.


Algebraic Constructions

The Natural Numbers

The beginning of developing an axiomatic number system starts with the natural numbers { 0, 1, 2, 3, ... }, which are constructed using the Peano Axioms. In this approach, we define everything in terms of a "starting element" 0 and a "successor function" S(a). This set, combined with the addition operation, forms a commutative monoid, but fails to form an addative group, lacking inverses.

The Ring of Integers

To extend the natural numbers into a full ring, we include additive inverses (a.k.a. "negatives") for all the natural numbers. This yields the ring of integers.

The Field of Fractions of the Rationals

Similarly to how the natural numbers lacked additive inverses to make it a group, the integers lack multiplicative inverses to make it a field. As the integers form an integral domain, we can extend them to a field of fractions, yielding the rational numbers.


A Precise Number System

The limitations of the algebraic representation are obvious if you try to create a natural number for 10,000: Stack Overflow! It turns out this is a very inefficient way to represent numbers.

The next question I had is how can we define an infinite precision number system. Fixed-size approximations such as Float or Double are just that; addition is technically not even associative.

Finite Length Truncations

To solve this problem, we first create an object Truncation that represents any finite length decimal. This is modeled after IEEE floating points, with a sign bit, exponent, and significant. However, for infinite precision, the length of the significant is unbounded. However, as it is a vector, it must be finite. Along with these truncations, we define a Zero object. These are captured in Scala's BigDecimal type.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.