MathGroup Archive 2008

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

Search the Archive

Re: NDSolve and Piecewise


M.G. Bartlett wrote:

> I am having some trouble with getting Piecewise and NDSolve to play
> nicely together.  My problem is to find a solution to the heat flow
> equation with an arbitrary time-varying upper boundary condition and a
> Neumann-type lower boundary (steady head flow condition).  My code
> looks like this:
> 
> NDSolve[{D[u[t, x], t] == D[u[t, x], x, x],
>   u[t, 0] == Piecewise[{{t/10, 0 <= t < 5}, {(10 - t)/10, 5 <= t <
> 10}}],
>   u[0, x] == x/5, (D[u[t, x], x] /. x -> 5) == 1/5}, u, {t, 0, 10},
> {x, 0, 5}]
> 
> This returns and NDSolve::ndum error on my system, which past
> experience tells me is usually me leaving some symbolic value hanging

*snip*

The issue might arise from your piecewise function, which is not smooth 
enough: its first derivative does not exist at t == 0, 5, and 10 (kinks) 
(Mathematica returns Indeterminate for this cases, see below).

In[1]:=

f[t_] := Piecewise[{{t/10, 0 <= t < 5}, {(10 - t)/10, 5 <= t < 10}}, 0]
f'[t]
Plot[f[t], {t, -15, 15}]

Out[2]=
                         1                  1
Piecewise[{{0, t < 0}, {--, 0 < t < 5}, {-(--), 5 < t < 10},
                         10                 10

    {0, t > 10}}, Indeterminate]

Out[3]= [... triangle shape graph deleted ...]

Regards,
-- Jean-Marc


  • Prev by Date: Re: Debracketing array symbols
  • Next by Date: Re: NDSolve and Piecewise
  • Previous by thread: NDSolve and Piecewise
  • Next by thread: Re: NDSolve and Piecewise