Let us consider the derivative
D[Floor[x]*Sin[Pi*x]^2, x] // Simplify
Piecewise[{{Pi*Floor[x]*Sin[2*Pi*x], x > Floor[x]}}, Indeterminate]
The result is not correct as the plot
Plot[Floor[x]*Sin[Pi*x]^2, {x, -3, 3}]
and
Limit[(Floor[2 + h]*Sin[Pi*(2 + h)]^2 - Floor[2]*Sin[Pi*2]^2)/h, h -> 0]
0
show. It should be noticed that Wolfram|Alpha produces the same expression (see that screen ). The command Limit[D[Floor[x]*Sin[Pi*x]^2, x], x -> 2]
which results in 0
is not any workaround because the continuity of the derivative is not established. This is exercise 978 г) from the wellknown problem book on analysis by B. Demidovich and the answer there $\pi \lfloor x\rfloor \sin (2 \pi x)$ is correct. The same issue with the derivatives of RealAbs[Sin[Pi*x]^2]
and RealAbs[Sin[Pi*x]^3]
.
Are there workarounds for all the integer values of x
?
ResourceFunction["IsContinuousFunction"][D[Floor[x]*Sin[Pi*x]^2, x], x]
produces an incorrect answerFalse
as well asResourceFunction["FunctionDiscontinuities"][ D[Floor[x]*Sin[Pi*x]^2, x], x]
which results in{{C[1] \[Element] Integers && x == 2 C[1]}, {C[1] \[Element] Integers && x == 1 + 2 C[1]}}
. $\endgroup$Limit[D[Floor[x]*Sin[Pi*x]^2, x], x -> 2]
How should the correct answer be? $\endgroup$D
givesIndeterminate
at integer values? It does the same for e.g.D[Floor[x]*Sin[Pi/3*x]^2, x]
. This is probably a good thing since for some purposes one wants to regard the derivative of a step function as zero and for others as a Dirac comb. $\endgroup$Sin
for which Indeterminate is incomplete is also measure zero (which was sort of the point of my example) . One should get used to such things, if one wishes to use it productively. $\endgroup$D[UnitStep[x], x]
which results inPiecewise[{{Indeterminate, x == 0}}, 0]
with the derivative of the generalized functionD[HeavisideTheta[x], x]
which results in the generalized functionDiracDelta[x]
. Concerning your second comment, a bug is a bug. Unfortunately, the limitations of theD
command are not documented. $\endgroup$