MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Boundary conditions in NDSolve

  • To: mathgroup at
  • Subject: [mg56818] Re: [mg56773] Boundary conditions in NDSolve
  • From: Ramesh Raju Mudunuri <rameshrajum at>
  • Date: Fri, 6 May 2005 03:01:40 -0400 (EDT)
  • References: <>
  • Reply-to: Ramesh Raju Mudunuri <rameshrajum at>
  • Sender: owner-wri-mathgroup at

    The present version of NDSolve handles linear BVPs (Boundary Value
Problem) well. Your BVP is non-linear. NDSolve is excellent for
Initial Value Problems. It is very good at handling parabolic and
hyperbolic PDEsl. We can use these features to solve non-linear BVPs
with NDSolve. Here I mention two such methods.
    The first is the well known Shooting method, where we guess one or
more of the initial conditions and iterate using a non-linear solver
to get the boundary conditions right.For your problem, guess the value
of f at -L, and find the deviation of the solution at L. The following
function does that


Plot the function for different s to see where the roots are. It lets
us also know if there are multiple solutions. We can get a good guess
for FindRoot from the plot. For

A=-1; B=1; K=3; L=1


shows that there are atleast three solutions. The solutions can be
found easily as

Solution One


Solution Two


Solution Three


     In the second method, the same BVP can be posed as a steady state
version of a PDE (parabolic PDE in this case). Here we solve a PDE.
The method is more involved, and is problem dependent. However if the
physics of the problem is well known, it is usually not difficult to
construct a PDE. In case of multiple solutions, the initial conditions
determine the final steady state. Here is a solution corresponding to
solution Three above.

sol1 = f /.
   NDSolve[{-4*Sin[f[x, t]]*D[f[x, t],
          t] + D[f[x, t], x, x] ==
       K^2*Sin[f[x, t]],
      (D[f[x, t], x] /. x -> -L) == A,
      f[L, t] == B, f[x, 0] ==
       A*(x - L) + B}, f, {x, -L, L},
     {t, 0, 2}][[1]]
p2 = Plot[sol1[x, 2], {x, -L, L},
   PlotRange -> All, PlotRange -> All]

It can be seen that either method gives the same solution.


Hope this helps,


On 5/5/05, YZ <z at ***> wrote:
> Hello,
> when I NDSolve a 2nd order DE, I cant seem to give two boundary
> conditions at different point of an interval I am solving it on:
> NDSolve[{f''[x]==K^2*Sin[f[x]],f'[-L]==A, f[-L]==B},f,{x,-L,L}]
> produces good result, but i.e.
> NDSolve[{f''[x]==K^2*Sin[f[x]],f'[-L]==A, f[L]==B},f,{x,-L,L}]
>   ____here derivative is given at left edge, but the functi0n itself is
> given at the right edge___
> produces error:
> NDSolve::"bvlin"
> "The differential equation(s) and/or boundary conditions are not linear
> in the dependent variables. NDSolve requires linearity to compute the
> solution of a multipoint boundary value problem. "
> Is there a way around this?
> Thanks
> YZ

  • Prev by Date: Re: letrec/named let
  • Next by Date: Re: InitializationCell -> Toggle shortcut key
  • Previous by thread: Re: Boundary conditions in NDSolve
  • Next by thread: Re: Boundary conditions in NDSolve