Ref:
Jeremy Schiff and Bill Poirier
J. Chem. Phys. 136, 031102 (2012)
Michael J. W. Hall Dirk-André Deckert and Howard M. Wiseman,
PHYSICAL REVIEW X 4, 041013 (23 October 2014)
Verlet integration (Wikipedia)
Ernst Hairer and Gustaf Söderlind
SIAM Journal on Scientific Computing. 2005, vol. 26, no. 6, p. 1838-1851
%load_ext sage
from numpy import array,concatenate,isnan
from mpmath import erfinv
hbar=var('hbar',latex_name='\\hbar')
mu=var('mu',latex_name='\mu')
vars = ['x','y']; d = len(vars)
def argscript(self, *args): return "%s_{%s}"%(self.name(),','.join(map(repr, args)))
X = map(lambda nam:function(nam, print_latex_func=argscript),vars); x,y = X
n,m = var('n,m'); ind=[n,m]
# position of particle in world (n,m)
Enm=map(lambda x:x(*ind),X);show(Enm)
def Dminus(x,i):return(x-x.subs(ind[i]==ind[i]-1))
def Dplus(x,i):return(x.subs(ind[i]==ind[i]+1)-x)
Jnm = matrix(map(lambda e:[Dminus(e,i) for i in range(d)],Enm));show(Jnm)
# inverse Jacobian
Knm = matrix(map(lambda x: map(lambda y:y.normalize(),x),Jnm^(-1)))
show(Knm)