3

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

Sjoerd C. de Vries
  • 65,815
  • 14
  • 188
  • 323
swish
  • 7,881
  • 26
  • 48

2 Answers2

3

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

Sjoerd C. de Vries
  • 65,815
  • 14
  • 188
  • 323
  • 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
2

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.}} *)
b.gates.you.know.what
  • 20,103
  • 2
  • 43
  • 84
  • 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.gates.you.know.what Nov 18 '12 at 19:22