I was trying to integrate a continuous function with a kink and I did it two ways and both ways the plot of the result shows a discontinuity. I also later want to differentiate the Integrated function.
a=5;
DSolve[Y'[H] == Max[H, a], Y[H], H]
{{Y[H] -> C[1] + 1/2 (2 a H + (a - H)^2 UnitStep[-a + H])}}
or alternatively
Integrate[Max[H, a], H]
I get
$ \begin{array}{ll} \Big\{ & \begin{array}{ll} 5 H & H\leq 5 \\ \frac{25}{2}+\frac{H^2}{2} & \text{True} \end{array} \end{array} $
When I plot the output from the ODE or Plot what I get from the result of the Integration command, I get the same plot, of course, but with this discontinuity at $a$.
Plot[1/2 (2 a H + (a - H)^2 UnitStep[-a + H]), {H, 4.9, 5.1}]
I get:
Why is this happening? If I do other operations with this function, is Mathematica gonna treat it as a continuous function or a discontinuous one? I can't remember my math right now but this new function should be differentiable also right since it was the result of an Integration?
When I do this:
FullSimplify[D[1/2 (2 a H + (a - H)^2 UnitStep[-a + H]), H]]
I get:
$ \begin{array}{ll} \{ & \begin{array}{ll} 5 & H<5 \\ H & H>5 \\ \text{Indeterminate} & \text{True} \end{array} \end{array} $
Is the fact that I am getting this Indeterminate
in the middle something to do with the discontinuity?
Plot[1/2 (2 a H + (a - H)^2 UnitStep[-a + H]), {H, 4.9, 5.1}, PlotPoints -> 300]
$\endgroup$D[ UnitStep[x], x]
,UnitStep
is a discontinuous function at0
. $\endgroup$1/2 (2 a x + (a - x)^2 UnitStep[-a + x])
is a continuous and even differentiable function whose derivative should beMax[x,a]
. I guess MMA is not able to figure this out and I need to communicate it to MMA somehow. $\endgroup$Exclusions->None
. If you plotPiecewiseExpand[1/2 (2 a h + (a - h)^2 UnitStep[-a + h])]
you also get the same gap ath=5
althoughD[PiecewiseExpand[1/2 (2 a h + (a - h)^2 UnitStep[-a + h])],h]
does not have theIndeterminate
piece; butPlot
"sees" some discontinuity in both functions, and inreasing the setting forPlotPoints
reduces the size of gap, andExclusions->None
removes it. (Mma V 8.04.0, Windows Vista 64bit) $\endgroup$