1705 shaares
869 private links
869 private links
2 results
tagged
algebra
How can a calculator program perform an exact calculation involving arithmetic operations, roots, trigonometric functions, etc? It's a difficult task. Here is how it can be done.
- rational type: bignum for both nom and denom
- recursive real arithmetic (RRA):
- represent a real number as a computation that maps from a precision value (a rational) to the rational result etc.
- for composite expression, compute the precision value needed for each of its components (e.g. for 2pi to be shown with a precision of 0.01, pi needs to be calculated to 0.005 precision)
- determine the exact equality between RRA
- undecidable but decidable for a finite set of ops (proven by Dan Richardson, 1994), but slow
- the optimization
- represent every number as an exact rational times a RRA. (e.g. (3/2)pi)
- hard code the common types of RRA (sin, log, ..) whose identity can be checked directly.
- for uncommon types of RRA, just store RRA (e.g. pi * sqrt(2))
the result: the digits shown on screen are always 100% correct. 99% of calculation gets perfect UX.
The SQL Join can be thought of as the follows:
- A join is a lookup
- A join is a nested loop over rows
- A join is a nested loop over columns
- A join is compatible alternate realities
- A join is flatMap
- A join is the solution to the N+1 problem
- A join is paths through a graph
- A join is a minimal model
- A join is typechecking
- A join is an operation in the Set monad
- A join is the biggest acceptable relation
- A join is a…join
- A join is a ring product
These are nice ways to illustrate a non-trivial algebraic structure.