I want to numerically solve the following exemplary partial differential equation in discretized form. My question is more about the technique how one would implement this in Mathematica (not about a specific solution to the equation). The discretized equation reads as follows:
f[n+1,j]=f[n]+dt*(f[n,j]+j*(f[n,j+1]-f[n,j]))
where n
is e.g. the n-th time step (n*dt
) and j
e.g. the j-th spatial step (j*dx
).
Note that the initial function f[0,j] shall be given for all j
(one can restrict it e.g. to the interval j=[-100,100]
).
I tried to implement it with FoldList[]
but fail to match the dimensions of my array. Is FoldList[]
the wrong idea here or how could one do it?
Help is very much appreciated. Thank you!
In principle, I could also implement it with loops. However, I wonder whether this is the most performant way.
NDSolve
exists and can handle PDEs? $\endgroup$NDSolve
won't apply to the equation I need to solve eventually (integro-differential equation). $\endgroup$NDSolve
will handle better than your implementation of Euler's method. $\endgroup$