Re: Please, can someone explain this small function?
- To: mathgroup at smc.vnet.net
- Subject: [mg50744] Re: Please, can someone explain this small function?
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sat, 18 Sep 2004 05:49:31 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 9/17/04 at 1:16 AM, REMOVEcole.turner at liwest.at (Cole Turner)
wrote:
>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!
>thanks a lot in advance!!!!
In the code, "mon" is a local function that computes a x^(b-1) from the two arguments a and {b}.
The built in function MapIndexed applies a specified function to every element of a list and the index of that element. The index is supplied to the function as a one element list, i.e., {n} where n is the index. So,
MapIndexed[mon, p1] simply computes every term of a polynomial in x given the coefficients in list p1.
Now having answered your posted question, I am curious as to why someone would write a function to compute the GCD of two polynomials given there is a built in function, PolynomialGCD that handles any two polynomials including those with more than one variable.
--
To reply via email subtract one hundred and four