We changed our privacy policy. Read more.
13

I'll write the equation short as $$\ddot x(t)+c\dot x(t)=a(t,x(t))$$ to separate the "easy" linear parts from the non-linear and forcing terms. On the first method The claimed order of the method is two, the implemented order is one. This is due to the implementation of the first derivative as a one-sided difference quotient. Changing that to the ...


4

Let's do it for the left boundary point $x=a$, and for simplicity assume $a=0$. To implement $u_x$=0 at $x$=0, assume the function $u(x)$ is even in the vicinity of $x$=0, and let the grid points be $x_0=0$, $x_1=h$, etc. Then, using the symmetry of the function, $u(-x_1)=u(x_1)$, the second derivative evaluated with the standard second-order accurate ...


1

I know this is a little bit late, but there's a third party library in Python which solve PDEs using FD, it is called findiff. Check it out.


Only top voted, non community-wiki answers of a minimum length are eligible