Re: Problems with differentiating Piecewise functions
- To: mathgroup at smc.vnet.net
- Subject: [mg86963] Re: [mg86930] Problems with differentiating Piecewise functions
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Thu, 27 Mar 2008 08:19:21 -0500 (EST)
- References: <200803260955.EAA09634@smc.vnet.net>
On 26 Mar 2008, at 10:55, hlovatt wrote:
> If I set up a piecewise function and differentiate it:
>
> In[112]:= pw1 = Piecewise[{{x^2, x <= 0}, {x, x > 0}}]
>
> Out[112]= \[Piecewise] {
> {x^2, x <= 0},
> {x, x > 0}
> }
>
> In[113]:= pw1 /. x -> 0
>
> Out[113]= 0
>
> In[114]:= pw1d = D[pw1, x]
>
> Out[114]= \[Piecewise] {
> {2 x, x < 0},
> {1, x > 0},
> {Indeterminate, \!\(\*
> TagBox["True",
> "PiecewiseDefault",
> AutoDelete->False,
> DeletionWarning->True]\)}
> }
>
> In[115]:= pw1d /. x -> 0
>
> Out[115]= Indeterminate
>
> Then at the joins between the pieces I get Indeterminate values,
> because the limit x <= 0 has become x < 0 after differentiation. Does
> anyone know a solution to this problem?
>
> Thanks,
>
> Howard.
>
What do you mean by "a solution to this problem"? You have a
function that is not differentiable at 0 and you would like it's
derivative to have a value there? You can't expect a "solution to a
problem" when you do not tell us what is the problem (except the fact
that not all functions are differentiable - but that's life).
Note that is your pieceise function is actually differentiable than
the derivative is defined everywhere:
pw2 = Piecewise[{{x^2, x <= 0}, {x^3, x > 0}}];
pw2d = D[pw2, x]
Piecewise[{{2*x, x < 0}, {0, x == 0}}, 3*x^2]
This is also as it should be. What else would you expect?
Andrzej Kozlowski
- References:
- Problems with differentiating Piecewise functions
- From: hlovatt <howard.lovatt@gmail.com>
- Problems with differentiating Piecewise functions