Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

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

Search the Archive

Re: Replacing terms and expanding one at a time

  • To: mathgroup at
  • Subject: [mg1836] Re: [mg1804] Replacing terms and expanding one at a time
  • From: adams (Adam Strzebonski)
  • Date: Mon, 7 Aug 1995 20:24:26 -0400

You can use a series for replacement. Then only the coefficents
at "significant" powers of y are computed:

In[1]:= e = x^10; rep = {x-> a1 y + a2 y^2 + a3 y^3 + a4 y^4};

In[2]:= (e2 = Normal[Series[ e /. rep, {y,0,15}]]);//Timing

Out[2]= {6.05 Second, Null}

In[3]:= rep1 = {x -> Series[a1 y + a2 y^2 + a3 y^3 + a4 y^4,  

(* The lowest order "unsignificant" term in x^10 will be here
   (a1 y)^9*O[y]^7 = O[y]^16 *)

In[4]:= (e3 = Normal[e/.rep1]);//Timing

Out[4]= {0.0833333 Second, Null}

In[5]:= e2-e3

Out[5]= 0

Adam Strzebonski

Begin forwarded message:

>From: Stephen Corcoran <corcoran at>
>Subject: [mg1804] Replacing terms and expanding one at a time
>Organization: Oxford University

Suppose I have an expression like

e = x^10,

where I want to replace x by something like

rep = {x-> a1 y + a2 y^2 + a3 y^3 + a4 y^4}

I then want to expand e, keeping terms up to say , order 15. I can do  
by using:

e2 = Normal[Series[ e /. rep,{y,0,15}]]

Presumably, however, this is a relatively inefficient way of  
proceeding as it
involves manipulation of the product of 10 4th degree polynomials.   
Is there
a way to replace one of the x's at a time, and then do the  
something like:

e2 = x^9 (a1 y + a2 y^2 + a3 y^3 + a4 y^4)
e3 = x^8 (a1^2 y^2 + ..... + a4^2 y^8)
e4 = x^7 (a1^3 y^3 + ..... + a4^3 y^12)
e5 = x^6 (a1^4 y^4 + ..... + 4 a3 a4^3 y^15)
and so on ?

If so, is there any better in terms of speed and/or memory usage?  Is  
more or less what Mathematica does anyway?

Stephen Corcoran,		email:	corcoran at  
Dept. of Statistics,			corcoran at  
University of Oxford,
1, South Parks Road		phone:  (01865) 272879
OXFORD, OX1 3TG			fax:	(01865) 272595

  • Prev by Date: Re: RealDigits
  • Next by Date: question: solution/algorithms on train problem
  • Previous by thread: Re: Replacing terms and expanding one at a time
  • Next by thread: Re: RealDigits