0
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Why reinvent the wheel when NDSolve exists and can handle PDEs? $\endgroup$ – Chris K Nov 15 '17 at 19:41
  • $\begingroup$ You are right, but as far as I know NDSolve won't apply to the equation I need to solve eventually (integro-differential equation). $\endgroup$ – Display Name Nov 15 '17 at 19:43
  • $\begingroup$ You are probably right. Downloaded the .nb file, but where is the code? $\endgroup$ – Display Name Nov 15 '17 at 20:00
  • 1
    $\begingroup$ @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. $\endgroup$ – Chris K Nov 15 '17 at 20:28
  • $\begingroup$ 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. $\endgroup$ – Display Name Nov 15 '17 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.