Please, can someone explain this small function?

• To: mathgroup at smc.vnet.net
• Subject: [mg50703] Please, can someone explain this small function?
• From: Cole Turner <REMOVEcole.turner at liwest.at>
• Date: Fri, 17 Sep 2004 01:16:51 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```input: two polynomials as lists
output: the GCD

methinks, this is the Euclidean Algorithm, what I don't get is how the
"mon" is constructed here and what exactly the "MapIndexed" function
does here - the MATHEMATICA help wasn't too helpful!

Cole ***

In[1]:=
myGCD[p1_List,p2_List]:=
Module[{mon,x,pol1,pol2,num},
mon[a_,{b_}]:=a*x^(b-1);
pol1=Factor[Plus@@MapIndexed[mon,p1]];
pol2=Factor[Plus@@MapIndexed[mon,p2]];
num=Numerator[pol1/pol2];
CoefficientList[pol1/num,x]
];
In[2]:=
myGCD[{1,1,-2,-2,1,1},{-2,-3,1,3,1}]
Out[2]=
{-1,-1,1,1}

--
Johnny: [plugging back in the runway lights]
"Just kidding."
('Airplane!', 1980)

```

• Prev by Date: Re: Help about "coin-run" problem......
• Next by Date: Plot Question
• Previous by thread: problem rendering GIF formatted files