MathGroup Archive 2005

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

Search the Archive

Re: Replace in recursive equations

  • To: mathgroup at
  • Subject: [mg54392] Re: Replace in recursive equations
  • From: David Bailey <dave at>
  • Date: Sun, 20 Feb 2005 00:07:51 -0500 (EST)
  • References: <cv6s9k$6lr$>
  • Sender: owner-wri-mathgroup at

Skirmantas wrote:
> The last sentence of my previous message about Inverse got somehow
> scrambled. I meant "I have to re-input the output to get the result." 
> One more quick question. Suppose I have a recursive equation F[n+1]==a
> F[n]. I want to replace F[n]->FF[n]+Q for _all_ n's. Q is a constant.
> What is the best way to do it? The left side should become FF[n+1]+Q
> and the right a(FF[n]+Q). Any help would be appreciated. 

I think you really mean for all instances of the function F - I  mean, 
you would presumably want to replace F[3] if it appeared in the 
equation. Thinking about it that way, the answer is easy:

eq = (F[n + 1] == a F[n])

eq /. F[z_] -> FF[z] + Q

      Q + FF[1 + n] == a*(Q + FF[n])

If you think you might need nested expressions - F[F[n]+1] - then you 
will need to use //. . However, it is best to use this only if you need 
to because if you make a mistake you can easily put Mathematica in a loop.

David Bailey

  • Prev by Date: Re: How do I get a DSolve'd function
  • Next by Date: Re: Why does Inverse[M] hesitate?
  • Previous by thread: Re: Replace in recursive equations
  • Next by thread: computing cumulative sum for list