sholloway / agents-playground

MIT License
4 stars 0 forks source link

Numerical Systems #151

Open sholloway opened 1 month ago

sholloway commented 1 month ago

Summary

What is a number? Numbers are arguably easy to grok when dealing on them on a whiteboard. There a sets of numbers that exhibit certain characteristics.

Types of Numbers

Type Symbol Description
Natural Numbers $\mathbb{N}$ Whole numbers starting from 0.
Integers $\mathbb{Z}$ Positive and negative counting numbers including 0.
Rational Numbers $\mathbb{Q}$ Numbers that can be expressed as a ratio (i.e. fractions). Includes the set of integers.
Real Numbers $\mathbb{R}$ Numbers that correspond to points on a line (think ruler). Includes the rational set of numbers.
Irrational Numbers $\mathbb {R} \setminus \mathbb{Q}$ The set of real numbers that are not rational. For example $\sqrt{2}$.
Imaginary Numbers $\mathbb{I}$ The set of numbers that are a product of a real number and an imaginary component i.
Complex Numbers $\mathbb{C}$ The set of numbers including real numbers, imaginary numbers, and sums and differences of real and imaginary numbers. For example, the number x where $x = a + bi$.
Hypercomplex Number-system extensions. For example quaternions ($\mathbb{H}$) and octonions.

Positional Number Systems

A positional system represents numbers is a technique of representing numbers in which the position of each digit contributes to the overall value of the number. Each digit is multiplied by some factor based on it's position. The decimal system is an example of this.

Examples System Base Allowed Digits Notes
Hindu-Arabic 10 [0 - 9] May have evolved due to humans having 10 fingers.
Binary 2 [0, 1] Used by electronics due to the ease of implementing with circuits.
Ternary 3 [0, 1, 2] or [-1, 0, 1] Used in some circuitry.
Quaternary 4 [0,1,2,3] Not widely used. Useful for doing arithmetic of hexadecimal numbers. Used in 2D Hilbert Curves and can represent genetic code in DNA.
Octal 8 [0 - 7] Largely replaced by Hexadecimal. The program chmod uses it for file permissions.
Hexadecimal 16 [0 - 9, A - F] Used by programmers over Octal and Binary. URI character codes are hexadecimal pairs prefixed with %.

Positional number system use exponents to signify the significance of each digit in a number. The number 413.72 in decimal is equivalent to: $$4 10^2 + 1 10^1 + 3 10^0 + 7 10^{-1} + 2 * 10^{-2} $$

Python Numerical Types

Equality

Numeric equality should not be determined with ==. Rather, the following methods should be used.

Representing Numerical Values in Python

Out of the Box

Third Party Options

Coding Techniques

Performance vs Precision

Use benchmark tests to compare the same set of calculations between ints, floats, Decimals, and Fractions.

The Core Problem

The engine needs a way to represent numbers that enables both flexibility for the programmer but also accuracy and precision that is appropriate for the tasks any given simulation is trying to accomplish.

Spatial Topology

Thoughts

sholloway commented 4 weeks ago

Need to evaluate the Reverse R technique for constructing a projection matrix.

https://tomhultonharrop.com/mathematics/graphics/2023/08/06/reverse-z.html

sholloway commented 2 weeks ago

Consider the different rotational techniques.