3
$\begingroup$

Lets say I have an ordinary differential equation:

$$\frac{dy(x)}{dx}=a \cdot e^x$$

I would like to solve this equation numerically. I could use for example Euler method or other explicit or implicit scheme to solve initial value problem (having one initial condition). To solve boundary value problem (having two conditions) I could use central difference scheme:

$$\frac{dy(x)}{dx}=\frac{y_{i+1}-y_{i-1}}{2 \Delta x}$$

and create system of equations, which after solution would provide $y(x_i)$ values and $a$ parameter value.

However if I want to solve initial value problem with central difference scheme there is one equation missing. I have too many unknown function values.

Is there some trick, or other equation I could add to state the problem in the right way, so that number of unknown values is equal to the number of equations?

$\endgroup$
3
$\begingroup$

A centered difference in the sense you have set up is possible, but isn't really what you want: you end up with parallel tracks for even and odd indices and end up being a factor of two inefficient. What you really should do is simply evaluate the RHS of the equation at the midpoint of a grid. To wit, define $x_n = x_0 + n \Delta x$. Then the difference equation for the IVP looks like

$$\frac{y_{n+1}-y_n}{\Delta x} = a \cdot e^{(x_n+x_{n+1})/2}$$

This is equivalent to a numerical quadrature using the midpoint rule. With your initial condition, you may solve for all $y_n$.

$\endgroup$

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.