1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Initial value problem, finite differences

  1. Mar 9, 2016 #1
    1. The problem statement, all variables and given/known data
    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.

    2. Relevant equations

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


    3. The attempt at a solution

    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: Mar 9, 2016
  2. jcsd
  3. Mar 10, 2016 #2

    andrewkirk

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    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)##.
     
  4. Mar 10, 2016 #3
    Thank you verymuch for your answer. I don't know if thats 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.
     
  5. Mar 10, 2016 #4

    andrewkirk

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    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##.
     
  6. Mar 10, 2016 #5
    Can you help me to extrapolate to second order then? I'm not sure how to do that.
     
  7. Mar 10, 2016 #6

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    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]
     
  8. Mar 10, 2016 #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: Mar 10, 2016
  9. Mar 10, 2016 #8

    andrewkirk

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    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##.
     
  10. Mar 10, 2016 #9
    Thank you verymuch to both of you.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Initial value problem, finite differences
  1. Initial value problem (Replies: 7)

  2. Initial-value problem (Replies: 2)

  3. Initial-value problem (Replies: 5)

Loading...