Backslide introduced in 9.0, persisting through 11.0.1
I try to solve a boundary value problem of coupled ODEs. For reference, when I solve this set of equations it works without any problems:
eq1 = {y'[x] == Piecewise[{{z[x], x < 5}, {y[x], x > 5}}]};
eq2 = {z'[x] == Piecewise[{{2 z[x] + 1, x < 5}, {2 y[x] + 1, x > 5}}]};
eqs = {eq1, eq2, y[0] == 1, z[10] == 0};
sol1 = NDSolve[eqs, {y, z}, {x, 0, 10},
Method -> {"Shooting",
"StartingInitialConditions" -> {y[0] == 1, z[0] == 1}}]
When I try to use more than 2 sections in the piecewise function I receive the following error:
eq1 = {y'[x] ==
Piecewise[{{z[x], x < 5}, {y[x], 8 > x > 5}, {2 z[x], x > 8}}]};
eq2 = {z'[x] == Piecewise[{{2 z[x] + 1, x < 5}, {2 y[x] + 1, x > 5}}]};
eqs = {eq1, eq2, y[0] == 1, z[10] == 0};
sol1 = NDSolve[eqs, {y, z}, {x, 0, 10},
Method -> {"Shooting",
"StartingInitialConditions" -> {y[0] == 1, z[0] == 1}}]
NDSolve::bvdisc: NDSolve is not currently able to solve boundary value problems with discrete variables. >>
I searched for a solution to this error online but non of the offered solutions helped. I don't understand why mathematica reads at as discrete variables when more than 2 sections are included. Same error appears whenever a boundary of the form a<x<b
is set in the piecewise function. It is important to note that for initial boundary problems, there are no issues. For example:
eq1 = {y'[x] ==
Piecewise[{{z[x], x < 5}, {y[x], 8 > x > 5}, {2 z[x], x > 8}}]};
eq2 = {z'[x] == Piecewise[{{2 z[x] + 1, x < 5}, {2 y[x] + 1, x > 5}}]};
eqs = {eq1, eq2, y[0] == 1, z[0] == 0};
sol1 = NDSolve[eqs, {y, z}, {x, 0, 10}]
Yields
{{y -> InterpolatingFunction[{{0., 10.}}, <>],
z -> InterpolatingFunction[{{0., 10.}}, <>]}}
Does anyone have a solution to this?
Thanks in advance.