Re: polynomial operations through CoefficientList
- To: mathgroup at smc.vnet.net
- Subject: [mg44766] Re: polynomial operations through CoefficientList
- From: "Peltio" <peltio at twilight.zone>
- Date: Tue, 25 Nov 2003 00:45:35 -0500 (EST)
- References: <bps3jo$9pu$1@smc.vnet.net>
- Reply-to: "Peltio" <peltioNOSP at Miname.com.invalid>
- Sender: owner-wri-mathgroup at wolfram.com
"Paolo Bientinesi" wrote >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] productList[cf1_,cf2_]:=ListConvolve[cf1, cf2, {1, -1}, 0] >and the list >{-1,k1-k3,-2 k2} >for p1[x]+p2[x] You need some padding here. If you can supply the missing coeffients in your input, such as in cf1 = {1,k1,-2 k2}; cf2 = {-2,-k3,0} You just have to sum the two lists sumList[cf1_,cf2_]:= cf1+cf2 otherwise you'll have to add a couple of lines to pad the shortest list with zeros up the the lenght of the longest one. Something like this would do: sumList[cf1_,cf2_]:=Module[ {n=Max[Length[cf1],Length[cf2]]}, PadRight[cf1,n]+PadRight[cf2,n] ] I haven't had a chanche to test the procedures, though. Check'em out prior to using them. cheers, Peltio invalid address in reply-to. Crafty demunging required to mail me.