The problem is caused by using SetDelayed in the definition of DG
. The derivative is not evaluated until it is used, and when it is, it is a derivative with respect to a constant x
. So, either use Set
in the definition of DG
or force evaluation prior to use.
Plot[Evaluate@DG[x, 0.3], {x, 0, 1}, Exclusions -> None]