Re: List quastion -- polynomial arithmetic operations

From: Bart Demoen (bmd_at_cs.kuleuven.ac.be)
Date: 10/18/04


Date: Mon, 18 Oct 2004 21:39:41 +0200

Cesar Rabak wrote:
> Can I feel a bit or irony here ;-)

Rhetoric question :-)

> So let's see:
>
> We agree in giving to lists of integers the semantic meaning of
> polynomial coefficients. It remains we agree on the convention.
>
> 1) Can we settle on increasing order from left to right?

Yes. But let's be as specific as possible:

[-3,5,0,17] represents a polynomial in some variable (say x)
of the form

        17*x^3 + 5*x - 3

>
> 2) The result of the operations shall be lists representing the
> resulting polynomials?

Yes. But we need to agree on the pathological cases ...
My suggestion is:

[-3,5,0,17,0,0] is not a good representation of the same polynomial
as above - i.e. I prefer no "leading zeros"

except perhaps

when the polynomial is just 0: do we represent it
by an empty list [] or by [0] ? I prefer the latter, but if anybody
posts code, it should be clear which convention is used.

>
> 3) And a specific predicate can bring the decimal representation?

Arithmetic on polynomials (represented with reversed lists of their
cooeficients) and decimal arithmetic (where ints are represented as
reversed lists of their decimal expansion) look similar, but they
are also different: for polynomials ?- prod([3],[4],[12]). should
succeed. For decimal aritmetic, [12] isn't even the proper
representation of any number. Another difference is that a number has
one global sign, while for a polynomial, every subterm can have its own
sign (I know, Knuth contains representations of numbers that are more
complicated than I am hinting at here, but let's first do the simple
thing).

The representation suggested by someone else in this thread had its
merits as well - the one with a list of terms coef(a,k).

Code anyone ?

Maybe as a warmup, we need a predicate to print out a representation
of a polynomial in a readable form - something like:

        ?- print_poly([-3,0,-18,5],x).
         5x^3 - 18x^2 - 3

And another predicate that "removes leading zeros" (after adding two
polynomials for instance - after multiplication, there should be no need
for that).

Cheers

Bart Demoen

Code anyone ?



Relevant Pages

  • Re: Number Theory problem: seeking Calculus example
    ... polynomials, and ask whether all of this information ... The list of references in this paper is the most ... mentioned in the following two lists of well known ... it seems that a group of mathematicians ...
    (sci.math)
  • Re: how to speed up some lisp code?
    ... polynomials are represented as a defstruct with a field that contains the ... > The integers in the lists are small: ... > The sorts of things I need to do with monomials: ... > The sorts of things I need to do with polynomials: ...
    (comp.lang.lisp)
  • how to speed up some lisp code?
    ... I'm using a data type I'll call a "monomial": these are sorted lists ... These could have thousands of monomials ... The sorts of things I need to do with polynomials: ...
    (comp.lang.lisp)
  • Re: how to speed up some lisp code?
    ... time when I need to compare monomials of different lengths. ... Does equal traverse the lists, ... (cons -1 MONO) ... consider storing the polynomials backwards (least ...
    (comp.lang.lisp)
  • Re: An instance of Russells paradox?
    ... >>infinite generalization of the arity of every predicate (I got this ... the representation ... > of lists is actually syntactic sugar for the binary term ... notation, the list notation, and the operator notation. ...
    (sci.logic)