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}]
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]
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.}} *)
f
has (possibly) multiple solutions other than x=0
, which you can get using RootSearch.
$\endgroup$
Commented
Nov 18, 2012 at 19:22
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... $\endgroup$