Message Boards Message Boards

0
|
13213 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Piecewise function does weird things when differentiated

Posted 9 years ago

First of all, when I plot the function like this, I get the seeming discontinuity, but when zooming in, it becomes smaller and smaller, suggesting it's a visual bug (or so I assume, perhaps it's on purpose), but when I then differentiate it, it gives me this, which I did not expect at all looking at the first graph. What's going on here? How can I get the "true" derivative, as it would be if the original function was continuous (and I thought it was, perhaps you guys can also tell whether or not this is indeed the case).

Thanks!

POSTED BY: Frederik Faye
2 Replies

Hmmm,

I think the gap is due to the method how Mathematica produces plots, gathering values at different positions and refining and so. The other question: Tan[ x ] = 1 means x = Pi / 4 , and for this x both constituents of your functions have the same values as well as their derivatives:

In[17]:= y1 = 1 - Tan[x]/2;
y2 = Cot[x]/2;
y1 /. x -> Pi/4
y2 /. x -> Pi/4

Out[19]= 1/2

Out[20]= 1/2



  (\!\(
   \*SubscriptBox[\(\[PartialD]\), \(x\)]\ y1\)) /. x -> Pi/4
   (\!\(
   \*SubscriptBox[\(\[PartialD]\), \(x\)]\ y2\)) /. x -> Pi/4

   -1

   -1

But the second derivatives are different, meaning the derivative of the composite function is not smooth. exactly as you see it. So it seems to me nothing is weird.

Look at

Plot[{y1, y2}, {x, 0, 1.5}, Plot[{y1, y2}, {x, 0, 1.5}, PlotStyle -> {Red, Blue}] 

Plot[Evaluate[{D[y1, x], D [y2, x]}], {x, 0, 1.5},  PlotStyle -> {Red, Blue}] 

Plot[Evaluate[{D[y1, x, x] , D[ y2, x, x]}], {x, 0, 1.5},  PlotStyle -> {Red, Blue}]
POSTED BY: Hans Dolhaine
Plot[Piecewise[{{1 - Tan[x]/2, 0 <= Tan[x] && Tan[x] < 1}, {Cot[x]/2,1 <= Tan[x]}}, 0], {x, 0, Pi/2}]

enter image description here

POSTED BY: Simon Cadrin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract