From charlesreid1

Polynomial Representation of Numbers

All of the real numbers of a given radix can also be expressed as a polynomial, where the variable is the radix.

For example, in base 10, we can split a number up into its ones, tens, hundreds, and so on. Suppose we have a number n,

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle n = 125 = 1 \times 100 + 2 \times 10 + 5 \times 1 }

This is equivalent to a polynomial representation in terms of the radix (10):

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle n = 125 = 1 \times 10^2 + 2 \times 10^1 + 5 \times 10^0 }

and if we replace the 10 with an x, we get a polynomial:

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle n = 125 = x^2 + 2 x + 5 }

This generalizes to larger numbers:

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle n = 3,654,987 = 3 \times 10^6 + 6 \times 10^5 + 5 \times 10^4 + 4 \times 10^3 + 9 \times 10^2 + 8 \times 10^1 + 7 \times 10^0 }

That's just a polynomial with as many terms as digits, and the unknown Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle x} replacing the base:

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle n = 3 x^6 + 6 x^5 + 5 x^4 + 4 x^3 + 9 x^2 + 8 x + 7 }

It also generalizes to binary numbers or hex numbers:

This number becomes the polynomial:

(where, for binary numbers, the set of possible coefficients is just the set .)

Here is a hex number, converted to the equivalent polynomial:

Replacing the letters with their decimal equivalents, we get the base 10 equivalent number:

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle 11 \times 16^3 + 14 \times 16^2 + 14 \times 16^1 + 15 \times 16^0 = 48,879 }

Python for Radix Conversions

Note that the radix conversions above (some non-decimal base into decimal base) are straightforward to do with Python - when you create an integer object, you can pass a string containing the number, then pass a second argument that specifies the radix:

$ python

>>> int('101010',2)
42

>>> int('BEEF',16)
48879

>>> int('DEADBEEF',16)
3735928559

Flags