Message Boards Message Boards

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

Piecewise function does weird things when differentiated

Posted 9 years ago
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