$\frac{du}{dt} = \frac{d}{dx}[\frac{1}{x^2+1}\frac{du}{dx}]$

I am trying to approximate this pde with a finite difference scheme but I am confused with the d/dx. Do I just take the derivative of 1/(x^2+1) and d/dx * du/dx = d^2/dx. Or is it a product rule?


You have two options, either do the product rule and then discretize, or discretize the equation as is. I'll derive them both:

Product Rule $$\frac{du}{dt} = \frac{d}{dx}\left[\frac{1}{x^2+1} \frac{du}{dx}\right] $$ $$\frac{du}{dt} = \frac{d}{dx}\left[\frac{1}{x^2+1} \right]\frac{du}{dx} + \frac{1}{x^2+1}\frac{d^2u}{dx^2} $$ $$\frac{du}{dt} = -\frac{2x}{(x^2+1)^2}\frac{du}{dx} + \frac{1}{x^2+1}\frac{d^2u}{dx^2} $$

Then you discretize that. For example using central differences for space and forward for time:

$$u_i^{n+1} = u_i^n + \Delta t\left(-\frac{2x_i}{(x_i^2+1)^2}\frac{u_{i+1}^n-u_{i-1}^n}{2\Delta x} + \frac{1}{x_i^2+1}\frac{u_{i+1}^n - 2u_i^n + u_{i-1}^n}{\Delta x^2} \right) $$

Then you simply solve that computing $u^{n+1}_i$from the data in the previous time step, starting with the initial condition of your problem.

As is

Alternatively, you could discretize the equation as is. There you treat all of $$\frac{1}{x^2+1} \frac{du}{dx} $$ as if it was a single function. For example:

$$\frac{d}{dx}\left[\frac{1}{x^2+1} \frac{du}{dx}\right] \approx \frac{1}{2\Delta x}\left(\left.\frac{1}{x_{i+1}^2+1} \frac{du}{dx}\right|_{i+1} - \left.\frac{1}{x_{i-1}^2+1} \frac{du}{dx}\right|_{i-1}\right) $$

Then you discretize each of the derivatives again, but using $i+1$ and $i-1$ as the center points. $$ \frac{1}{2\Delta x}\left(\left.\frac{1}{x_{i+1}^2+1} \frac{du}{dx}\right|_{i+1} - \left.\frac{1}{x_{i-1}^2+1} \frac{du}{dx}\right|_{i-1}\right) \approx \frac{1}{2\Delta x}\left(\frac{1}{x_{i+1}^2+1}\left( \frac{u_{i+2}-u_i}{2 \Delta x}\right) - \frac{1}{x_{i-1}^2+1} \left( \frac{u_i - u_{i-2}}{2 \Delta x}\right)\frac{du}{dx}\right)$$

Then taking into account the time derivative, the final equation is: $$ u_i^{n+1} =u_i^n + \Delta t\left(\frac{1}{x_{i+1}^2+1}\left( \frac{u_{i+2}^n-u_i^n}{4 \Delta x^2}\right) - \frac{1}{x_{i-1}^2+1} \left( \frac{u_i^n - u_{i-2}^n}{4 \Delta x^2}\right)\right)$$

Both approaches are correct. Not that in the second you end up calling points that 2 steps away from the point of interest. This makes the boundary conditions a bit harder to take into account, so the first method is usually preferred.


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.