# Ordinary Differential Equations¶

## Finite Difference Formulas¶

We define the backward difference operator by:

Repeated application gives:

We can also derive a formula for where is any real number, independent of :

Now we can express the following general integral using the function value from either left () or right () hand side of the interval :

Code:

>>> from sympy import var, simplify, integrate
>>> var("nabla t h")
(nabla, t, h)
>>> s = integrate((1-nabla)**(-t/h), (t, 0, h))
>>> simplify(s)
h*nabla/(-log(1 - nabla) + nabla*log(1 - nabla))
>>> s.series(nabla, 0, 5)
h + h*nabla/2 + 5*h*nabla**2/12 + 3*h*nabla**3/8 + 251*h*nabla**4/720 + O(nabla**5)
>>> s2 = s*(1-nabla)
>>> simplify(s2)
-h*nabla/log(1 - nabla)
>>> s2.series(nabla, 0, 5)
h - h*nabla/2 - h*nabla**2/12 - h*nabla**3/24 - 19*h*nabla**4/720 + O(nabla**5)


Keeping terms only to third-order, we obtain:

Similarly:

Code:

>>> from sympy import var
>>> var("f0 f1 f2 f3")
(f0, f1, f2, f3)
>>> nabla1 = f0 - f1
>>> nabla2 = f0 - 2*f1 + f2
>>> nabla3 = f0 - 3*f1 + 3*f2 - f3
>>> 24*(f0 + nabla1/2 + 5*nabla2/12 + 3*nabla3/8)
-59*f1 - 9*f3 + 37*f2 + 55*f0
>>> 24*(f0 - nabla1/2 - nabla2/12 - nabla3/24)
f3 - 5*f2 + 9*f0 + 19*f1


## Integrating ODE¶

Set of linear ODEs can be written in the form:

(1)

For example for the Schrödinger we have

Now we need to choose a grid , where is some uniform grid. For example :

where . We also need the derivative, for the exampe above we get:

Now we substitute this into (1):

We can integrate this system from to on a uniform grid :

where and we use some method to approximate the integral, see the previous section.

## Radial Poisson Equation¶

Radial Poisson equation is:

(2)

The left hand side can be written as:

So the Poisson equation can also be written as:

(3)

Now we determine the values of , and the behavior of and . The equation determines up to an arbitrary constant, so we set and now the potential is determined uniquely.

The 3D integral of the (number) density is equal to the total (numeric) charge, which is equal to (number of electrons). We can then use the Poisson equation to rewrite the integral in terms of :

So in the limit , we get the equation:

by integrating (and requiring that vanished in infinity to get rid of the integration constant), we get for :

Integrating (3) directly, we get:

We already know that behaves like in infinity, so vanishes. Requiring itself to vanish in infinity, the left hand side simplifies to and we get:

Last thing to determine is . To do that, we expand the charge density and potential (and it’s derivatives) into a series around the origin:

And substitute into the equation (2):

We now multiply the whole equation by and then set . We get , so . We put it back into the equation to get:

This must hold for all , so we get the following set of equations for :

from which we express for all . We already know the values for and from earlier, so overall we get:

in particular:

So we get the following series expansion for and :

### Analytic Testing Example¶

Good analytic testing solution, that satisfies the asymptotic relations is:

#### Previous topic

Wigner D Function

Linear Algebra