MathGroup Archive 2006

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

Search the Archive

Re: Beginner--Error in Series expansion

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68185] Re: Beginner--Error in Series expansion
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Thu, 27 Jul 2006 05:30:11 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 7/26/06 at 2:26 AM, abdou.oumaima at hotmail.com wrote:

>When I'm trying to find a power series of this function, It doesn't
>yield the correct expression:

>Z[L_] = Sum[(((-1)^Lp/(
>L - Lp + 1))*(1/ksi^Lp)), {Lp, 0, L}] - (-1)^L Log[1 + ksi]/ksi^(L +
>1)

>devZ[L_] = Normal[Series[Z[L], {ksi, 0, 2}]] devZ[3]

>I get: devZ[3]= 1/4 -1/ksi^3+1/2 ksi +(ksi-ksi^2/2)/ksi^4. This code
>must yield: devZ[3]= ksi/5 - ksi^2/6 +0(ksi^3)

>How to correct this error.

You are using Set ('=') where I would normally expect SetDelayed (':=') to be used. When I make that change, I get

In[3]:=
Z[L_]:=Sum[(((-1)^Lp/(
      L-Lp+1))*(1/ksi^Lp)),{Lp,0,L}]-(-1)^L Log[1+ksi]/ksi^(L+1)

In[4]:=
devZ[L_]:=Normal[Series[Z[L],{ksi,0,2}]]
devZ[3]

Out[5]=
ksi/5 - ksi^2/6

The difference between Set and DelayedSet is Set immediately evaluates the right hand side and assigns the result of that evaluation to the left hand side. This is generally not what you want when creating your own functions. Instead, you generally want to delay evaluation until values for the variables have been supplied. This is what DelayedSet does for you.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Graphics export quality-methods and defaults
  • Next by Date: Re: Table to find lower and upper estimate
  • Previous by thread: Re: Beginner--Error in Series expansion
  • Next by thread: RE:Beginner--Error in Series expansion