Initial value problem, finite differences

In summary, Ray's solution uses the information embedded in the function f, whereas mine doesn't. I suggest you use that.
  • #1
Telemachus
835
30

Homework Statement


Given an initial value problem:

##x'(t)=f(t,x)\,,x(t_0)=x_0##

Use centered finite differences to approximate the derivative, and deduce a scheme that allows to solve the (ivp) problem.

Homework Equations



For centered finite differences ##\displaystyle\frac{dx}{dt} \approx \frac{x(t+h)-x(t-h)}{2h}##

The Attempt at a Solution


[/B]
First, I discretized the variable t: ##t_i=t_0+ih, \forall i=0,1,2,...,N##

So then, using the formula for finite differences, and calling ##x(t_i)=x_i##

I've obtained:
##x_{i+1}-x_{i-1}=2hf(t_i,x_i)##

The problem is that if I try some test function ##f(x,t)## I think that the ivp gives inssuficient data to solve the problem, I get more ##x_i's## than equations when trying to solve. So I think I'm doing something wrong.
 
Last edited:
Physics news on Phys.org
  • #2
You're right. If you only consider the ##x_k## for ##k=0,1,...,n## and ##x'_k## for ##k=1,...,n-1## then, since ##x_0## is given, you have ##(n+1)+(n-1)=2n## unknowns and ##1 + (n-1) + (n-1)=2n-1## equations, so you are one equation short.

Why not extrapolate on second differences? If you bring in unknowns ##x_{-1}, x'_0, x''_1,x''_2,x''_3## then you have five more unknowns.
Add an equation that expresses ##x''_1## as an extrapolation from ##x''_2,x''_3##.
Then you can get the needed additional five equations from the relationships between ##x'_k,\ x''_k,\ ## and ##x_k## in the time steps from -1 to 5, plus using the value of ##x'_0=f(t_0,x_0)##.
 
  • Like
Likes Telemachus
  • #3
Thank you verymuch for your answer. I don't know if that's the purpose of the exercise, we have only worked with differential equations of first order in this course. Any other idea? how much error would I introduce if I set, for example ##x_1=0##? I think that wouldn't be more fictitious than interpolating to second order, it would give a second boundary condition. Perhaps working with forward finite differences would solve the problem, but it asks to do it with centered differences.
 
  • #4
If you don't want to go to second differences, the next best thing I can think of is to add the equation
$$x_1=x_0+hx'_0=x_0+hf(t_0,x_0)$$
That would be less accurate than using second differences because it assumes curvature (second derivative) is zero at ##t_0##. How much less accurate would depend on the curvature.

By the way, using second differences does not change the nature of the differential equation to second order. It remains first order. You are just using an additional term of the Taylor Series in approximating the values of ##x_k##.
 
  • Like
Likes Telemachus
  • #5
Can you help me to extrapolate to second order then? I'm not sure how to do that.
 
  • #6
From ##x'(t) = f(t,x(t))## we have
[tex] x''(t) = f_t(t,x(t)) + f_x(t,x(t)) x'(t) = f_t(t,x(t)) + f_x(t,x(t)) f(t,x(t)),[/tex]
where ##f_t = \partial f/ \partial t## and ##f_x = \partial f/ \partial x##. Thus,
[tex] x''(0) = f_t(0,x_0) + f_x(0,x_0) f(0,x_0)[/tex]
Use this, plus ##x'(0) = f(0,x_0)## in the expansion
[tex] x(0+h) \doteq x_0 + x'(0) h + \frac{1}{2} x''(0) h^2 [/tex]
 
  • Like
Likes Telemachus
  • #7
Thank you verymuch. How do I use this last result in the finite difference scheme I've posted before?

From this I would deduce the value for ##x_{1}##?
 
Last edited:
  • #8
The following is a simple linear extrapolation that assumes a constant third derivative at ##t_2##. First add the three centred difference equations
$$x''_k=\frac{x'_{k+1}-x'_{k-1}}{2h}$$
for ##k=2, 3##. Then add the extrapolation equation
$$x''_1=x''_2-(x''_3-x''_2)$$
That's four extra equations for only three extra unknowns.

An even simpler, slightly less accurate, approach would just add the unknowns ##x''_1,x''_2##, the associated two difference equations, and an equation ##x''_1=x''_2##.

Actually, I've just read Ray's post, and I like his solution better, because it uses the information embedded in the function ##f##, whereas mine doesn't. I suggest you use that. And in answer to your most recent question, yes, that last formula in his post will give you the value of ##x_1##.
 
  • Like
Likes Telemachus
  • #9
Thank you verymuch to both of you.
 

Related to Initial value problem, finite differences

1. What is an initial value problem?

An initial value problem is a type of differential equation that involves finding a function that satisfies a given set of initial conditions. These conditions typically include the value of the function at a specific point or interval, as well as its derivative at that point or interval.

2. What are finite differences?

Finite differences are a method for approximating the derivatives of a function at discrete points. This involves taking the difference between the function values at two nearby points and dividing by the distance between those points. This can be used to solve initial value problems numerically.

3. How are finite differences used to solve initial value problems?

Finite differences are used to approximate the derivatives in the initial value problem, which allows us to turn the problem into a system of algebraic equations that can be solved numerically. This method is particularly useful for complex initial value problems that cannot be solved analytically.

4. What are the advantages of using finite differences to solve initial value problems?

One advantage is that the method is relatively easy to implement and does not require advanced mathematical knowledge. Additionally, it can be used to solve a wide range of initial value problems, including those that involve nonlinear functions or complex boundary conditions.

5. Are there any limitations to using finite differences to solve initial value problems?

One limitation is that the accuracy of the solution depends on the step size used in the finite differences. A smaller step size will result in a more accurate solution, but it also increases the computational time. Additionally, this method may not work well for problems with discontinuous or highly oscillatory solutions.

Similar threads

  • Differential Equations
Replies
3
Views
559
  • Calculus and Beyond Homework Help
Replies
1
Views
750
Replies
5
Views
1K
  • Calculus and Beyond Homework Help
Replies
15
Views
1K
  • Calculus and Beyond Homework Help
Replies
15
Views
2K
Replies
7
Views
2K
  • Calculus and Beyond Homework Help
Replies
7
Views
423
  • Calculus and Beyond Homework Help
Replies
14
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
623
  • Calculus and Beyond Homework Help
Replies
1
Views
994
Back
Top