MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Derivatives of user-defined control-flow functions

On 4 Oct 2004, at 19:18, Maxim wrote:
>  Notice that while
> Mathematica's rule for the differentiation of If can be handy, it is,
> strictly speaking, not correct; for example:
> In[9]:=
> D[If[x == 0, 0, Sin[x]^2/x], x]
> Out[9]=
> If[x == 0, 0, (2*Sin[x]*Cos[x])/x - Sin[x]^2/x^2]
> while the correct value for the derivative at zero is 1.
> Maxim Rytin
> m.r at
One may also argue that you defined this function incorectly, at least 
if you were intending to differentiate it at 0.

Normal[Sin[x]^2/x + O[x]^2]


the "correct" definition should be

If[x == 0, x, Sin[x]^2/x]

in which case differentiation will give the right answer.

Andrzej Kozlowski
Chiba, Japan

  • Prev by Date: Re: Special case of plotting a 3D function
  • Next by Date: Re: Re: suggestion for frontend
  • Previous by thread: Re: Derivatives of user-defined control-flow functions
  • Next by thread: Re: Thichness of Plot does not change Solved