# Numerically finding a derivative jump of a function

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}]


-
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 : mathoverflow.net/q/165038/14414 – Rajesh Dachiraju Jan 4 '15 at 4:23

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}]


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

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


-
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.}} *)

-
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