Re: List quastion -- polynomial arithmetic operations
From: Bart Demoen (bmd_at_cs.kuleuven.ac.be)
Date: 10/18/04
- Next message: Heath Hunnicutt: "Re: How to create a square grid like chess board???"
- Previous message: Bart Demoen: "Re: How to create a square grid like chess board???"
- In reply to: Cesar Rabak: "Re: List quastion -- polynomial arithmetic operations"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 ?
- Next message: Heath Hunnicutt: "Re: How to create a square grid like chess board???"
- Previous message: Bart Demoen: "Re: How to create a square grid like chess board???"
- In reply to: Cesar Rabak: "Re: List quastion -- polynomial arithmetic operations"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|