Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How would I numerically find where a function has derivative jumps?

In particular, I'm working with this function:

f[k_?IntegerQ,y_?NumberQ] := 
   x /. FindRoot[Nest[y/4 Sin[\[Pi] #] &, x, k] == x, {x, 1}]

k=1 k=2

share|improve this question
You can use Ctrl+D and the GetCoordinate from the Drawing Tools. – b.gatessucks Nov 18 '12 at 14:35
@b.gatessucks I ask for a general method. – swish Nov 18 '12 at 14:40
A suggestion: you could try using GradientFilter[] on a sampling of your data, and then use the methods here to pick out extrema, whose locations should hopefully correspond to where your jump discontinuities are... – J. M. Nov 18 '12 at 16:39
@swish : You might this concept useful : – Rajesh Dachiraju Jan 4 '15 at 4:23
up vote 3 down vote accepted

If the function is not to wild Interpolation could be of use:

t = Table[{x, f[2, x]}, {x, 0, 4, 1/10000.}];
it = Interpolation[t]

Large values of second derivatives are probably caused by discontinuities in the first derivative:

discontinuities = Reap[Do[If[Abs[it''[x]] > 2000, Sow[{x, it[x]}]], {x, 0, 4, 1/1000.}]][[2, 1]]

ListLinePlot[t, Epilog -> {Red, Point@discontinuities}]

Mathematica graphics

BTW You may have trouble with this function. Take for instance f[3,x]:

Plot[f[3, x], {x, 0, 4}, PlotPoints -> 100]

Mathematica graphics

share|improve this answer
I will try it now, I just need to know where the jumps are so I can include a better intervals for finding roots in the definition of a function. – swish Nov 18 '12 at 17:17

You can maximize the derivative :

f[x_] = Piecewise[{{0, x < 2}, {Sqrt[x - 2], x >= 2}}];

NMaximize[Abs[f'[x]], x]

(* {1.84154*10^6, {x -> 2.}} *)
share|improve this answer
Function is numerical, so we need a numerical derivative, and there could be multiple jumps, I would want to find them all. – swish Nov 18 '12 at 15:00
@swish You can calculate the numerical derivative and find all its maxima. Then you're dealing with finding all the local maxima of a function (which is hard in general). – acl Nov 18 '12 at 17:13
The equation defining your f has (possibly) multiple solutions other than x=0, which you can get using RootSearch. – b.gatessucks Nov 18 '12 at 19:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.