       RE: polynomial operations through CoefficientList

• To: mathgroup at smc.vnet.net
• Subject: [mg44752] RE: [mg44729] polynomial operations through CoefficientList
• From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
• Date: Tue, 25 Nov 2003 00:45:20 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```>-----Original Message-----
>From: Paolo Bientinesi [mailto:pauldj at cs.utexas.edu]
To: mathgroup at smc.vnet.net
>Sent: Monday, November 24, 2003 6:05 AM
>To: mathgroup at smc.vnet.net
>Subject: [mg44752] [mg44729] polynomial operations through CoefficientList
>
>
>Hello,
>2 polynomials directly from their CoefficientList's?
>
>example: the polynomials I'm considering are
>p1[x_] := 1 + k1 x - 2 k2 x^2
>p2[x_] := -2 -k3 x
>
>Given
>cf1 = {1,k1,-2 k2}
>and
>cf2 = {-2,-k3}
>
>I would like to get the list
>{-2,-2 k1-k3,4 k2-k1 k3,2 k2 k3}
>for p1[x]*p2[x]
>
>and the list
>{-1,k1-k3,-2 k2}
>for p1[x]+p2[x]
>
>without performing operations like
>
>CoefficientList[
> cf1.Table[x^i,{i,0,Length[cf1]-1}]*
> cf2.Table[x^i,{i,0,Length[cf2]-1}], x]
>
>Thanks!
>--
>Paolo
>
>pauldj at cs.utexas.edu		        paolo.bientinesi at iit.cnr.it
>

Paolo,

With

In:= cf1 = {1, k1, -2 k2};
In:= cf2 = {-2, -k3};

In:= With[{len = Max[Length /@ {##}]},
PadRight[#, len] & /@ Unevaluated[Plus[##]]] &[cf1, cf2]

Out= {-1, k1 - k3, -2 k2}

Adjusting for same length appears to be a bit nasty!

Multiplication is easier:

In:= ListConvolve[cf1, cf2, {1, -1}, 0]
Out=
{-2, -2 k1 - k3, 4 k2 - k1 k3, 2 k2 k3}

To me however it appears to be much more appropriate to use Mathematicas
built-in abilities to deal with polynomials, and come back to coefficient
lists only when necessary for the results (if ever).

In:= p1 = Normal[SeriesData[x, 0, cf1]]
Out= 1 + k1*x - 2*k2*x^2

In:= p2 = Normal[SeriesData[x, 0, cf2]]
Out= -2 - k3 x

In:= CoefficientList[p1 + p2, x]
Out= {-1, k1 - k3, -2 k2}

In:= CoefficientList[p1*p2, x]
Out= {-2, -2 k1 - k3, 4 k2 - k1 k3, 2 k2 k3}

--
Hartmut Wolf

```

• Prev by Date: RE: [Integrate] Why two results of same eq. are different?
• Next by Date: Re: Remote Display on Linux still unsolved !
• Previous by thread: Re: polynomial operations through CoefficientList
• Next by thread: AW: Conversion Function -> List