Coder Social home page Coder Social logo

exact-real's Introduction

The purpose of this exercise is to explore and implement exact real arithmetic. Exact real arithmetic combines arbitrary precision with incremental computation.

  • The focus is on correctness and clarity. Using Haskell we avoid all low-level distractions.

  • I use a symmetric redundant ternary representation. So the radix is 3 and the digit range is {-2,-1,0,1,2}. I believe this is the sweet spot between binary and higher radix representations: radix 2 forces too much precision in the operands, whereas radix 4 is too complex.

  • We capture the essence of each arithmetical operation in a state machine. Each state transition typically produces one more digit of the result. This is motivated by separation of concerns: a transition function is independent of the data structures used to represent a stream of digits. The correctness of these state machines is therefor not coupled to the details of how to drive forward a computation.

  • Efficiency is treated as a separate concern. State machines described at a high level of abstraction can be compiled to an adequate low-level computational substrate.

In retrospect, I believe this approach was unnecessarily complicated. But I learned a lot from it, about Haskell and about exact real arithmetic. Having the addition kernel magically produced by Z3 stood in the way of gaining deeper understanding.

exact-real's People

Contributors

jeroennoels avatar

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.