MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Pattern matching "on the fly"


Note,  however, that myexpand method gives a "general" answer to Tony 
MacKenzie's problem, which the series method does not. For example, 
suppose we wish to work in a in a quotient of the polynomial ring on x 
and y, where the following condition holds:

In[1]:=
Unprotect[Times];

In[2]:=
((x^k_)*(y^l_)=0)/;k+l>6;

In[3]:=
Protect[Times];

Suppose we now want to compute (x+y)^1000000. The series method is not 
applicable (I think) but:

myexpand[f_, n_] :=
   Fold[Expand[#1^2*If[#2 == 1, f, 1]] &, f, Rest[IntegerDigits[n, 2]]]

In[8]:=
myexpand[x+y,1000000]//Timing

Out[8]=
                             1000000             
999999                      999999  1000000
{0.02 Second, x        + 1000000 x       y + 1000000 x y       + 
y       }

In principle one could do this with PolynomialReduce but I think  it 
would  take quite a while...

Andrzej Kozlowski
Toyama International University
JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/

On Sunday, July 29, 2001, at 03:07  PM, Allan Hayes wrote:

> From the results below it looks as if for getting the first three tems 
> of
> (1+x)^(10^6)  (the original example). Andrzej's method is quicker as a
> one-off calcuation. But the Series method that Bob and I suggested does 
> some
> cacheing and is quicker for repeats.
>
>
>
>



  • Prev by Date: Re: A Penny for Thought
  • Next by Date: Re: Pattern matching "on the fly" + Developer`ClearCache[]
  • Previous by thread: Re: Pattern matching "on the fly"
  • Next by thread: Re: Pattern matching "on the fly"