Bug introduced after 9.0.1, persisting through 12.3.1. Fixed in 13.0
I have identified a bug in DSolve
when differential equation includes a Piecewise
statement with a discontinuity at the boundary.
I want help figuring out how to set the correct border condition for this differential equation that includes a Piecewise
statement with a discontinuity at the boundary.
My tests are in WolframCloud
$Version
12.3.0 for Linux x86 (64-bit) (May 10, 2021)
The differential system is simple
eqns={
r[0]==0,
D[r[t],t]== Piecewise[{{a, 0<=t<c}},0] - b r[t]
}
Mathematica does find a solution using DSolve
, but it contains some intriguing results it's the wrong solution.
sol=Assuming[
And[a>0,b>0,c>0],
FullSimplify[
r[t]/.First@DSolve[eqns,r,t]
]
]
nsol=ReplaceAll[sol, {a->1,b->2,c->3}];
Plot[nsol, {t,-1,10}]
First, I would have expected the solution to be a zero constant for $t<0$, here is that I assume I'm not defining the border condition correctly.
Second, there is this term UnitStep[1-c]
, I don't see how c==1
is a special condition. I expected this to be UnitStep[t]
.
I'm expecting a solution like this
Piecewise[
{
{(1-Exp[-t b]) a/b, 0<t<c},
{(1-Exp[-c b]) Exp[-(t-c) b] a/b, c<t}
}
,0]
Mathematica is giving an incorrect answer and this has been reported to Wolfram Support, acknowledged as a bug, and the developers have been informed.
Questions:
What is the scope of this problem?
Do other discontinuous functions break DSolve
too?
Can this problem be reproduced in other versions and platforms?
DSolve
.NDSolve
gives the same result as 2nd graphic. $\endgroup$Piecewise[{{(a*(1 - Cosh[b] + Sinh[b]))/b, t == 1 && c > t}, {(a*(-1 + E^(b*c)))/(E^(b*t)*b), c <= t && ((t < 1 && c <= 1) || t > 1)}, {(a - a/E^(b*t))/b, (Inequality[0, LessEqual, t, Less, 1] && (c > 1 || c > t)) || (c > t && t > 1)}, {0, t < 0}}, (a*(-1 + E^(b*c)))/(E^b*b)]
i.sstatic.net/e8WaV.png $\endgroup$