       Re: hi,friends(8)

• To: mathgroup at smc.vnet.net
• Subject: [mg92196] Re: hi,friends(8)
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Mon, 22 Sep 2008 07:26:19 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <gb7o7i\$nas\$1@smc.vnet.net>

```China -->hk wrote:

> Can we use Mathematica to solve the following recurrence function problem?
> f[1,1]=1,f[m,n+1]=f[m,n]+2,f[m+1,n]=2*f[m,n],m,n are positive integers.f[m,n]=?

Mathematica can be used to solve partial difference equations; however,
one may have to do some work to get an answer.

*RSolve* is the function you are looking for. *Eliminate* is used to
rewrite two equations as only one. We find a general solution (w/o using
the condition f[1,1] == 1). Finally, using some intuition, we find a
suitable function for the coefficient C. So we have,

f[m,n] == -4 (-1 + 2^m) + 5 2^(-1 + m) Cos[(m + n) Pi]

Below is the step by step process describe above.

In:= RSolve[{f[m, n + 1] == f[m, n] + 2, f[m + 1, n] == 2*f[m, n],
f[1, 1] == 1}, f[m, n], {m, n}]

During evaluation of In:= RSolve::overdet: There are fewer
dependent variables than equations, so the system is overdetermined.

Out= RSolve[{f[m, 1 + n] == 2 + f[m, n], f[1 + m, n] == 2 f[m, n],
f[1, 1] == 1}, f[m, n], {m, n}]

In:= Eliminate[{f[m, n + 1] == f[m, n] + 2,
f[m + 1, n] == 2*f[m, n]}, f[m, n]]

Out= 4 + f[1 + m, n] == 2 f[m, 1 + n]

In:= RSolve[{4 + f[1 + m, n] == 2 f[m, 1 + n], f[1, 1] == 1},
f[m, n], {m, n}]

Out= RSolve[{4 + f[1 + m, n] == 2 f[m, 1 + n], f[1, 1] == 1},
f[m, n], {m, n}]

In:= RSolve[4 + f[1 + m, n] == 2 f[m, 1 + n], f[m, n], {m, n}]

Out= {{f[m, n] -> -4 (-1 + 2^m) + 2^(-1 + m) C[m + n]}}

In:= f[m, n] /. % /. {m -> 1, n -> 1}

Out= {-4 + C}

In:= f[m, n] /. %%[] /. C -> Function[k, 5 Cos[Pi k]]

Out= -4 (-1 + 2^m) + 5 2^(-1 + m) Cos[(m + n) \[Pi]]

In:= % /. {m -> 1, n -> 1}

Out= 1

In:= Plot3D[%%, {m, 1, 5}, {n, 1, 5}, PlotRange -> All]

Out= [...  Graphic deleted  ...]

Regards,
-- Jean-Marc

```

• Prev by Date: Re: ByteCount of imported machine-precision data matrix three times
• Next by Date: Re: labeling axes in a ContourPlot
• Previous by thread: Re: hi,friends(8)
• Next by thread: Re: hi,friends(8)