If all you have is a data encoding method....

Dec 30, 2011 13:28

Realization: Polynomials and indexed arrays of integers are, if not isomorphic, then *very* useful for understanding each other ( Read more... )

Leave a comment

Comments 7

miss_chance December 30 2011, 19:12:02 UTC
I <3 geekery!

Happy New Year!

Reply


sweh December 30 2011, 19:26:34 UTC
It becomes even more obvious when you think of a polynomial as a sigma equation
f(x)=sum(i=0->inf) a{sub i}x^i
ie
a0 + a1x + a2x^2 + a3x^3 + ...
which leads to a natural a[] as the representation

For full representation you need an infinitely sized array, or a lazy evaluation language :-)

Reply

vatine December 30 2011, 19:54:03 UTC
And if you have your arrays in the right (and by right, I actually mean "wrong") order, stored from highest to lowest index, computing the polynmomial for a given X turns into a simple reduce (or, if your language supports reducing from the tail-end, you can have the array in the right order).

To wit:
lambda(x, polynom): reduce lambda(sum, new-poly-factor): x*sum+new-poly-factor over polynom

Reply

sweh December 30 2011, 20:01:41 UTC
Trying to think how I'd do this in Orwell (language I last used in 1987). Hmm...

> f x a:as = f x a:as 0
> f x a:as i = a*x^i * f x as (i+1) if as <> []
> = a*x^i otherwise

The "a:as" expression means "single element a followed by a (potentially empty) list of more a's"

Reply


perspicuity December 30 2011, 21:00:42 UTC
i've got a book in "computational algebra" some years ago. fascinating stuff. polynomial goodness.

then consider polynomials and bases and the fun you can do there.

and gah. i can reference a book if you want. i'll have to find it later.

one can write a lot of neat perl/python for such things.

#

Reply

vatine December 31 2011, 15:28:56 UTC
There's always the joys of "iterated Newton-Raphson fractals". Essentially, take any polynomial, find its roots, then for a section of the complex plane, colour all points based on (a) what root is reached and (b) how long it takes to get there.

If you start from the roots, you can simply construct the polynomial and can skip the root-finding. It's also possible to do the root-finding mixed in with the point-colouring (find what root a given point tends to, see if that is a root previously found, if not add the root to the set of roots).

Reply


jason237 December 31 2011, 16:31:50 UTC
Ah yes, Linear Algebra.

Reply


Leave a comment

Up