Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Imposing normalization in numerical solution of of ODE

  1. Apr 17, 2015 #1
    Hello all,

    I would like to know how to impose a normalization condition to numerically solving an ODE. For simplicity lets consider the example
    [tex] \frac{dy}{dx}=y [/tex]
    You could use different methods using an initial value, but if you consider the interval [tex][x_0,x_1][/tex] and [tex] \int_{x_0}^{x_1} y(x)dx=1 [/tex] How would you impose that condition in a numerical scheme (instead of the initial value condition)?
    This arises in the context of PDEs over PDFs, such as Fokker-Planck equations. I consider the ODE case for simplicity.

    Thank you very much
  2. jcsd
  3. Apr 17, 2015 #2


    User Avatar
    Homework Helper
    Gold Member

    It must be a diabolical coincidence but in this very example the integral condition is equivalent to [itex]y(x_1)-y(x_0)=1[/itex]

    But,well i dont know a generic method to impose such conditions into the numerical solution process.
  4. Apr 17, 2015 #3
    It depends on the problem. In general you can introduce a tunable parameter, and then iterate on the parameter unit the integral constraint is satisfied.

    This particular ODE is invariant under the change of variables [itex] y = \alpha y^* [/itex]. However, the constraint is not invariant: [itex] \int y dx = \int \alpha y^* dx = 1 [/itex]. This allows us to solve for [itex] \alpha[/itex] using [itex] \alpha= 1 / \int y^* dx[/itex].

    Solving this problem then takes three steps. First, solve the ODE [itex] y^* = \frac{dy^*}{dx}[/itex] for some guess initial condition. Use something simple like [itex] y^*\left(x_0\right) = 1[/itex].

    Second, integrate [itex]\int y^* dx [/itex] to find [itex] \alpha[/itex].

    Finally, use [itex] y = \alpha y^* [/itex] to find [itex] y [/itex].
  5. Apr 17, 2015 #4
    If you solve in fourier space you will only have to make sure that your zero component of the transformed data is preserved in your numerical scheme.
  6. Apr 19, 2015 #5
    Thank you all for your responses. The analytic approach of invariant equations under change of variables is very interesting, and would work in this case, however I am looking for more generic approaches (if they exist). And about preserving your zero component in Fourier space, wouldn't it only preserve an additive constant in the solution?

    The thing is that this solution would be a stationary solution of a PDE, say for example
    [tex]\frac{\partial y}{\partial t}=\frac{\partial f(x)y(x)}{\partial x} -K\frac{\partial ^2 y(x)}{\partial x^2} [/tex]
    Then the stationary solution would be something like the example I posted for [itex]f(x)=1[/itex] applying the condition [itex]lim_{x \to \infty}y(x)=0[/itex], so if it was not stationary you normally could use a Finite Elements or Finite Differences scheme, so a question would also be: how would you implement the normalization condition in the FE and FD approach to preserve the normalization accross time?

    Thank you all
  7. Apr 19, 2015 #6
    Well the I did assume that the inteterval in the first post was the boundary of your system. Perhaps that was not the case?
    ## lim_{x\rightarrow \infty} y(x) = 0 ## probably isn't the easiest boundary condition to implent in a finite simulation. Have you considered transforming x such that infinity is moved to a finite value?
  8. Apr 19, 2015 #7
    Sorry, it was not the case, maybe I did not explain myself well. There's no boundary to the system. In fact the normalization condition would be [itex]\int_{-\infty}^{\infty} y(x) dx=1[/itex], but for purpose of computation it could be aproximated with [itex]\int_{x_0}^{x_1} y(x) dx[/itex] with an interval that's big enough, that's why the condition [itex]\lim_{|x| \to \infty} y(x)=0[/itex] (yes, there's also the simetric limit condition) helps, since you could find better approximations by widening the interval.

    But that conditions comes to place mainly when reducing the previous equation to a stationary sistem in the way
    [tex] 0=\frac{\partial}{\partial x} (f(x)y(x)) -K \frac{\partial ^2 y(x)}{\partial x^2}[/tex]
    Solving the first derivative means
    [tex]f(x)y(x)-K\frac{\partial y(x)}{\partial x}=A[/tex]
    But since that should be valid for all x, then [itex]A[/itex] should be 0 to satisfy the limit condition, and we are left with a similar system to the first I posted.
    But that is only to give a context, I am intereseted in the question of implementing the approximated normalization condition in a numerical scheme.

  9. Apr 20, 2015 #8
    First, as a general comment. The study of differential equations is a huge field. There is no general approach that allows one to solve all differential equations. Likewise there are no generic approaches that allow you to treat the integral constraint for all differential equations.

    I'm not sure that I'm following you. But this is not a well-posed problem. If you give me an initial condition and two boundary conditions then you've completely specified the PDE. By then requiring that the integral over the domain has to be equal to unity, you are over-constraining the problem. There is no guarantee that a solution exists.

    My statement "you can introduce a tunable parameter, and then iterate on the parameter unit the integral constraint is satisfied" is a very general approach. I then showed you how to use it with the ODE that you supplied.

    In general consider a 2nd order ODE with 1 boundary condition and 1 integral condition. I can solve this by using the supplied boundary condition, and and guessing the second boundary condition. For instances I could suppose that the second boundary condition is [itex] y(x_2)=\alpha[/itex]. Then the trick is to iteratively adjust [itex] \alpha [/itex] until the integral constrain is satisfied.

    Another approach is to reformulate the differential equation into a minimization problem (this works particular well for finite element methods). You can then use a penalty methods. The idea is to introduce a penalty function of the form [itex] c \left(\int y dx -1\right) [/itex] where [itex]c [/itex] is a large positive parameter. Since [itex]c [/itex] is large, the minimization will converge on a solution that approximately enforces [itex] \left(\int y dx -1\right) = 0 [/itex].
  10. Apr 25, 2015 #9
    Okay, thank you!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook