Backslide introduced in 9.0, persisting through 11.0.1
It is possible to numerically solve a differential equation if not-smooth data are involved?
For example the following instruction return the error NDSolve::bvdisc:
NDSolve[{-u''[x] == UnitBox[(x - 0.5) 0.5/0.2], u[0] == 0,
u'[1] == 0}, u, {x, 0, 1}]
NDSolve::bvdisc: NDSolve is not currently able to solve boundary value problems with discrete variables. >>
Here I suppose discrete variable means discontinuous functions but maybe the problem is completely different.
This error is reported in Mathematica 10, where the Finite Element Framework should be able to return weak, not classical, solutions and should be definitely able to deal with such a simple equation, but maybe we need to enable some option or methods.
Please note I know I can do
DSolve[{-u''[x] == UnitBox[(x - 0.5) 0.5/0.2], u[0] == 0,
u'[1] == 0}, u, {x, 0, 1}]
but in more complex scenarios I cannot hope to get an analytical answer.
DiscreteVariables
were added in V9 -- that is, the error is the result of some advance inNDSolve
that improves some area but is unreliable in another (hence the message)? (I do not know.) One can still achieve the V8 behavior viaf[x_?NumericQ] := UnitBox[...]
as Szabolcs has observed. $\endgroup$