Question: How to automate discretization of high order derivatives with maple


I am trying to discretize high order derivatives (typicaly of order 3-4) and I would like to use maple to avoid errors. Using this thread of discussion I got the following minimum example that illustrates the problem I am facing:


# central discretisation u_xx, i=1,..,n-1
dxc:=add([1,-2,1] *~ [u[i+k,j] $k=-1..1])/(h^2);

(u[i-1, j]-2*u[i, j]+u[i+1, j])/h^2



# we need to compute gradient(laplacian) on faces i+1/2,j and i-1/2,j.

#First diff(u_xx,x)|i+1/2,j
d1:=add([1,-1] *~ [dxc[i+p,j] $p=0..1])/(h);
#which should give
d1:=add([1,3,-3,1] *~ [u[i+k,j] $k=-1..2])/(h^3);

(((u[i-1, j]-2*u[i, j]+u[i+1, j])/h^2)[i, j]-((u[i-1, j]-2*u[i, j]+u[i+1, j])/h^2)[i+1, j])/h


(u[i-1, j]+3*u[i, j]-3*u[i+1, j]+u[i+2, j])/h^3



I would like maple to evaluate the first expression for d1 and give the second expression that I wrote manually.

Is there a way to do this ? (using simplify() does't produce anything)



Please Wait...