0

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.

NeverMind
  • 1,201
  • 7
  • 9
  • Why reinvent the wheel when NDSolve exists and can handle PDEs? – Chris K Nov 15 '17 at 19:41
  • You are right, but as far as I know NDSolve won't apply to the equation I need to solve eventually (integro-differential equation). – NeverMind Nov 15 '17 at 19:43
  • You are probably right. Downloaded the .nb file, but where is the code? – NeverMind Nov 15 '17 at 20:00
  • 1
    @DisplayName Depending on where the integral is, you might still be able to use the method of lines to convert your integro-differential equation into a large set of ODEs, which NDSolve will handle better than your implementation of Euler's method. – Chris K Nov 15 '17 at 20:28
  • Yeah, I tried this already to transform it into a system of ODEs, but wasn't successful either. Maybe I need to think a little bit more about it. – NeverMind Nov 15 '17 at 20:32
  • Well, I'm afraid your question is a bit too board at the moment. Anyway, you may want to read this post. – xzczd Nov 16 '17 at 04:10

0 Answers0