#hw26.txt. Katie McKeon. May 1, 2014. Help26:=proc() print(`ExpD2(M,N)`): end: #ExpD2(M,N): Let L(i,j) be the expected duration of the #walk starting at i,j on the MxN grid and ending when #(-,N), (-,0), (M,-) or (0,-) is reached, outputs the list #of lists [[L[1,1],...,L[1,N-1]],...[L[M-1,1],...L[M-1,N-1]]] ExpD2:=proc(M,N) local eq,var,i,j,var1, L,p: p:=1/4: var:=[seq([seq(L[i,j],j=1..N-1)],i=1..M-1)]: eq:={seq(seq(L[i,j]=p*L[i-1,j]+p*L[i+1,j]+p*L[i,j-1]+p*L[i,j+1]+1, j=1..N-1),i=1..M-1)}: eq:=subs({seq(L[i,0]=0,i=0..M),seq(L[i,N]=0,i=0..M), seq(L[0,j]=0,j=0..N),seq(L[M,j]=0,j=0..N)},eq): var1:=solve(eq,{seq(op(var[i]),i=1..M-1)}): subs(var1,var): end: #Data #ExpD2(2,2); # [[1]] #ExpD2(2,3); # [[4/3, 4/3]] #ExpD2(5,5); # [[10/3, 14/3, 14/3, 10/3], # [14/3, 20/3, 20/3, 14/3], # [14/3, 20/3, 20/3, 14/3], # [10/3, 14/3, 14/3, 10/3]]