Make Sinc' return 0 instead of Indeterminate

I want Sinc' to return 0, but instead it returns Indeterminate.

I've tried

Unprotect[Sinc]
Unprotect[Derivative]
Derivative[Sinc] ^= 0

But it doesn't work.

Maybe this needs to be similar to this (from the help files for Derivative)

f'[x_] := If[PossibleZeroQ[x], N[0, Precision[x]], (x Cos[x] - Sin[x])/x^2];
• Why not define your own function? – VF1 Feb 11 '14 at 23:13
• I'd be interested in knowing if the community considers this a bug – Rojo Feb 11 '14 at 23:48
• @Szabolcs yes. However, that single point is the whole point of having a Sinc function in the first place so this itches me a little – Rojo Feb 12 '14 at 1:18
• @Rojo I played a bit with piecewise functions and I think I know why this is not feasible: suppose the derivative were returned as a piecewise. Actually we might as well start from sinc[x_] := Piecewise[{{Sin[x]/x, x != 0}}, 1]. The mathematically proper derivative of Sinc should be what sinc'[x] returns. But now let's take the derivative of this once more: D[sinc'[x],x]. This will be a piecewise that's still 0 in the point $x=0$. However the actual second derivative sinc''(0) should be -1/3. This illustrates how Piecewise itself is unable to handle derivatives ... – Szabolcs Feb 12 '14 at 1:27
• ... in a mathematically correct way, and it's not difficult to see why. Since Piecewise won't give us proper derivative, it doesn't make a lot of sense to return a piecewise for Sinc'[x]. It would just delay the problem until the next derivative. OK, this is somewhat subjective, but after thinking this through I start to accept why they might have consciously made the decision not to both with Sinc'[x] in x=0. My point is that while they could have implemented Derivative[n][Sinc][x] to return a correct Piecewise for any n, taking another derivative of that result would fail anyway. – Szabolcs Feb 12 '14 at 1:28

Here is a slightly more robust way to modify the default behavior. It works for all positive derivatives of Sinc:

Unprotect[Sinc];
Sinc /: Derivative[n_Integer?Positive][Sinc] :=
Piecewise[{
{(-1)^(n/2)/(n + 1), # == 0 && EvenQ[n]},
{0, # == 0 && OddQ[n]},
{Derivative[n - 1][Cos[#]/# - Sin[#]/#^2 &][#], True}
}] &;
Protect[Sinc];

Usage:

Sinc'
(* 0 *)

Sinc''
(* -1/3 *)
• Derivative supports direct assignment without the need to unprotect. So Derivative[n_Integer?Positive][Sinc] := ... is sufficient (without TagSet or Unprotect). – Szabolcs Oct 11 '16 at 13:38
• @Szabolcs That's true, but the way WRI implements derivatives of built-in special functions is to associate them to the special function with TagSet. See e.g. <<GeneralUtilities`; PrintDefinitions[PolyLog]; PrintDefinitions[MittagLefflerE], etc... So, I follow the WRI way for Sinc. – QuantumDot Oct 12 '16 at 15:05

One solution is making your own function:

MySinc[x_] := Sinc[x]
Derivative[MySinc] ^=
If[# == 0, 0, Derivative[Sinc] // Evaluate] &;
MySinc
(* 1 *)
MySinc'
(* 0 *)

And then in expressions which use Sinc use expr/.Sinc->MySinc. To me this seems like the cleanest solution. However, this can be done with Sinc, too. But it is difficult to undo!

Unprotect[Sinc];
tmp = Derivative[Sinc] // Evaluate;
Derivative[Sinc] ^= If[# == 0, 0, tmp] &;
Protect[Sinc];
Sinc
(* 1 *)
Sinc'
(* 0 *)
• I supose i should accept this. It offers 2 good suggestions – pdmclean Feb 14 '14 at 21:38
• @pdmclean does the latter part not directly answer your question? – VF1 Feb 15 '14 at 1:13

The function is:

f[x_] = D[Sinc[x], x];
f[x]
Cos[x]/x - Sin[x]/x^2

In its current form, the value at x=0 is indeterminate. It is only when taking the limit as x->0 that a value emerges. Hence:

Limit[D[Sinc[x], x], x -> 0]
0

Or, more succinctly:

Limit[f[x], x -> 0]
0
• I of course agree that you need to take the limit but the same reasoning could be applied to Sinc alone. So I agree with @Rojo above that the reason to have a Sinc function should be that you don't have to evaluate Limit[Sin[x]/x,x->0] every time. It would be nice if the same was true for Sinc'. – sebhofer Feb 12 '14 at 16:51