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[1]. 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[1]:= 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[1]:= RSolve::overdet: There are fewer dependent variables than equations, so the system is overdetermined. Out[1]= 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[2]:= Eliminate[{f[m, n + 1] == f[m, n] + 2, f[m + 1, n] == 2*f[m, n]}, f[m, n]] Out[2]= 4 + f[1 + m, n] == 2 f[m, 1 + n] In[3]:= RSolve[{4 + f[1 + m, n] == 2 f[m, 1 + n], f[1, 1] == 1}, f[m, n], {m, n}] Out[3]= RSolve[{4 + f[1 + m, n] == 2 f[m, 1 + n], f[1, 1] == 1}, f[m, n], {m, n}] In[4]:= RSolve[4 + f[1 + m, n] == 2 f[m, 1 + n], f[m, n], {m, n}] Out[4]= {{f[m, n] -> -4 (-1 + 2^m) + 2^(-1 + m) C[1][m + n]}} In[5]:= f[m, n] /. % /. {m -> 1, n -> 1} Out[5]= {-4 + C[1][2]} In[6]:= f[m, n] /. %%[[1]] /. C[1] -> Function[k, 5 Cos[Pi k]] Out[6]= -4 (-1 + 2^m) + 5 2^(-1 + m) Cos[(m + n) \[Pi]] In[7]:= % /. {m -> 1, n -> 1} Out[7]= 1 In[8]:= Plot3D[%%, {m, 1, 5}, {n, 1, 5}, PlotRange -> All] Out[8]= [... Graphic deleted ...] Regards, -- Jean-Marc