1
$\begingroup$

The function Floor[x] is piecewise constant, hence its derivatives should be piecewise zero.

This is far from true in Mathematica

In[497]:= $Version

Out[497]= "10.1.0 for Microsoft Windows (64-bit) (March 24, 2015)"

The first and second derivatives in the interval $\frac{1}{2}\lt x \lt \frac{3}{2}$ are shown in these graphs

Plot[D[Floor[x], {x, 1}] /. x -> xx, {xx, 1/2, 3/2}, PlotRange -> All, 
 PlotLabel -> "y=Floor'[x]", AxesLabel -> {"x", "y"}]

enter image description here

Plot[D[Floor[x], {x, 2}] /. x -> xx, {xx, 1/2, 3/2}, PlotRange -> All,
  PlotLabel -> "y=Floor''[x]", AxesLabel -> {"x", "y"}]

enter image description here

We notice that the drivatives are far from zero even over a broad range of $x$.

In the standard documentation I have found no hint of this problem.

My question: is this a bug?

$\endgroup$
6
  • 1
    $\begingroup$ Mathematica 10.1 is quite old. I see different results than what you describe in more recent versions of the program. $\endgroup$
    – ktm
    Oct 10, 2018 at 13:18
  • 1
    $\begingroup$ Have you seen this, by any chance? $\endgroup$ Oct 10, 2018 at 13:33
  • $\begingroup$ @ user6014 Thank you for the hint. Could you perhaps show more details in an answer, i.e. how do the plots look in more recent versions? $\endgroup$ Oct 10, 2018 at 15:19
  • $\begingroup$ @ J. M. is somewhat okay Sorry, what do you mean by "this"? $\endgroup$ Oct 10, 2018 at 15:20
  • 1
    $\begingroup$ Thanks, click of "this" reveals that the problem is a dupilcate. In the answer provided here for M11 the bug has been removed. $\endgroup$ Oct 10, 2018 at 15:59

1 Answer 1

3
$\begingroup$

Starting in version M11, Floor'[x] evaluates:

Floor'[x] //TeXForm

$\begin{cases} 0 & x>\lfloor x\rfloor \\ \operatorname{Indeterminate} & \operatorname{True} \end{cases}$

Of course, this obscures the discontinuity at integer x. If you want to produce a derivative that can be integrated back to the original result, you can try using an equivalent HeavisideTheta representation:

{Plot[Floor[x], {x, 1/2, 3/2}], Plot[HeavisideTheta[x-1], {x, 1/2, 3/2}]}

enter image description here

Then:

D[HeavisideTheta[x-1], x]

DiracDelta[-1 + x]

Integrate[DiracDelta[-1+x],x]

HeavisideTheta[-1 + x]

$\endgroup$
1
  • $\begingroup$ @ Carl Wolf The hint on HeavisideTheta is most useful. It works also in V10. $\endgroup$ Oct 10, 2018 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.