Polynomials/Numbers
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,
This is equivalent to a polynomial representation in terms of the radix (10):
and if we replace the 10 with an x, we get a polynomial:
This generalizes to larger numbers:
That's just a polynomial with as many terms as digits, and the unknown replacing the base:
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:
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
polynomials useful mathematical objects, common enough for everyone, complex enough to keep you busy
Polynomials/Numbers - polynomial representations of numbers
Polynomials/Java - implementing a Polynomial class in Java Polynomials/Inheritance - using polynomials to illustrate inheritance (Java) Polynomials/Interface - using polynomials to illustrate interfaces (Java and Go)
Polynomials/Test Driven Development - how to write tests, explained using polynomials Polynomials/Timing - how to time code to measure performance
|