3
$\begingroup$

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

$\endgroup$
  • $\begingroup$ You can use Ctrl+D and the GetCoordinate from the Drawing Tools. $\endgroup$ – b.gates.you.know.what Nov 18 '12 at 14:35
  • $\begingroup$ @b.gatessucks I ask for a general method. $\endgroup$ – swish Nov 18 '12 at 14:40
  • $\begingroup$ 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... $\endgroup$ – J. M. will be back soon Nov 18 '12 at 16:39
  • $\begingroup$ @swish : You might this concept useful : mathoverflow.net/q/165038/14414 $\endgroup$ – Rajesh Dachiraju Jan 4 '15 at 4:23
3
$\begingroup$

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

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – swish Nov 18 '12 at 17:17
2
$\begingroup$

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.}} *)
$\endgroup$
  • $\begingroup$ Function is numerical, so we need a numerical derivative, and there could be multiple jumps, I would want to find them all. $\endgroup$ – swish Nov 18 '12 at 15:00
  • $\begingroup$ @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). $\endgroup$ – acl Nov 18 '12 at 17:13
  • $\begingroup$ The equation defining your f has (possibly) multiple solutions other than x=0, which you can get using RootSearch. $\endgroup$ – b.gates.you.know.what Nov 18 '12 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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