9
$\begingroup$

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

I've tried

Unprotect[Sinc]
Unprotect[Derivative]
Derivative[1][Sinc][0] ^= 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];
$\endgroup$
14
  • 1
    $\begingroup$ Why not define your own function? $\endgroup$
    – VF1
    Feb 11, 2014 at 23:13
  • 1
    $\begingroup$ I'd be interested in knowing if the community considers this a bug $\endgroup$
    – Rojo
    Feb 11, 2014 at 23:48
  • 2
    $\begingroup$ @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 $\endgroup$
    – Rojo
    Feb 12, 2014 at 1:18
  • 2
    $\begingroup$ @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 ... $\endgroup$
    – Szabolcs
    Feb 12, 2014 at 1:27
  • 2
    $\begingroup$ ... 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. $\endgroup$
    – Szabolcs
    Feb 12, 2014 at 1:28

3 Answers 3

2
$\begingroup$

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]
(* 0 *)


Sinc''[0]
(* -1/3 *)
$\endgroup$
2
  • $\begingroup$ Derivative supports direct assignment without the need to unprotect. So Derivative[n_Integer?Positive][Sinc] := ... is sufficient (without TagSet or Unprotect). $\endgroup$
    – Szabolcs
    Oct 11, 2016 at 13:38
  • $\begingroup$ @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. $\endgroup$
    – QuantumDot
    Oct 12, 2016 at 15:05
9
$\begingroup$

One solution is making your own function:

MySinc[x_] := Sinc[x]
Derivative[1][MySinc] ^= 
  If[# == 0, 0, Derivative[1][Sinc] // Evaluate] &;
MySinc[0]
(* 1 *)
MySinc'[0]
(* 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[1][Sinc] // Evaluate;
Derivative[1][Sinc] ^= If[# == 0, 0, tmp] &;
Protect[Sinc];
Sinc[0]
(* 1 *)
Sinc'[0]
(* 0 *)
$\endgroup$
2
  • $\begingroup$ I supose i should accept this. It offers 2 good suggestions $\endgroup$
    – pdmclean
    Feb 14, 2014 at 21:38
  • $\begingroup$ @pdmclean does the latter part not directly answer your question? $\endgroup$
    – VF1
    Feb 15, 2014 at 1:13
3
$\begingroup$

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
$\endgroup$
1
  • 1
    $\begingroup$ 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'. $\endgroup$
    – sebhofer
    Feb 12, 2014 at 16:51

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.