# Plot of the derivative of a function

I have a function functionSL as a function of t (t<0) where I want to find the extremum of the function and also find at which t it occurs. I took the derivative of functionSL with t which I wrote it as the function functionSLD.

d = 3; torootL[a_?NumericQ, t_?NumericQ, zl_?NumericQ, zh_?NumericQ] := a - NIntegrate[(zl y^d)/Sqrt[(1 - (zl/zh)^(d + 1) y^(d + 1)) (1 + t^2 (1 - (zl/zh)^(d + 1))^-1 - y^(2 d))], {y, 0, 1}, PrecisionGoal -> 6, Method -> "GlobalAdaptive"] zs[a_?NumericQ, t_?NumericQ, zh_?NumericQ] := zl /. FindRoot[torootL[a, t, zl, zh], {zl, 0.5, 0, 1}] intSL[a_?NumericQ, t_?NumericQ, zh_?NumericQ] := NIntegrate[With[{b = zs[a, t, zh]/zh}, (((-1)/(d - 1)) (zs[a, t, zh]^(2 d) (1 + t^2 (1 - (zs[a, t, zh]/zh)^(d + 1))^-1))^-1 zs[a, t, zh]^(2 d)) x^d ((1 - (b x)^(d + 1))/(1 - (zs[a, t, zh]^(2 d) (1 + t^2 (1 - (zs[a, t, zh]/zh)^(d + 1))^-1))^-1 (zs[a, t, zh] x)^(2 d)))^(1/2) - ((b^(d + 1) (d + 1))/(2 (d - 1))) x ((1 - (zs[a, t, zh]^(2 d) (1 + t^2 (1 - (zs[a, t, zh]/zh)^(d + 1))^-1))^-1 (zs[a, t, zh] x)^(2 d))/(1 - (b x)^(d + 1)))^(1/2) + (b^(d + 1)x)/((1 - (b x)^(d + 1)) (1 - (zs[a, t, zh]^(2 d) (1 + t^2 (1 - (zs[a, t, zh]/zh)^(d + 1))^-1))^-1 (zs[a, t, zh] x)^(2 d)))^(1/2)], {x, 0, 1}, MinRecursion -> 20, MaxRecursion -> 20, AccuracyGoal -> 12, PrecisionGoal -> 10, Method -> {"GlobalAdaptive", "SingularityHandler" -> Automatic}] functionSL[a_?NumericQ, t_?NumericQ, zh_?NumericQ] := ((-((1 - (zs[a, t, zh]^(2 d) (1 + t^2 (1 - (zs[a, t, zh]/zh)^(d + 1))^-1))^-1 zs[a, t, zh]^(2 d)) (1 - (zs[a, t, zh]/zh)^(d + 1)))^(1/2)/(d - 1)) + intSL[a, t, zh] + 1)/(4 zs[a, t, zh]^(d - 1)) functionSLD[t_] := Evaluate[Derivative[0, 1, 0][functionSLL][0.01, t, 1]] 

I took some sample values of functionSLD for some t,

In[44]:= functionSLD[0]  Out[44]= -3.58024*10^-12  In[48]:= functionSLD[-10]  Out[48]= 0.15527  In[90]:= functionSLD[-15]  Out[90]= 0.0477369  In[91]:= functionSLD[-16]  Out[91]= 0.041289  In[93]:= functionSLD[-16.5]  Out[93]= 0.039934  In[59]:= functionSLD[-17] // Quiet  Out[59]= 0.0424448  In[60]:= functionSLLP[-17.5]  Power::infy: Infinite expression 1/0. encountered.  NIntegrate::izero: Integral and error estimates are 0 on all integration subregions. Try increasing the value of the MinRecursion option. If value of integral may be 0, specify a finite value for the AccuracyGoal option.  NIntegrate::izero: Integral and error estimates are 0 on all integration subregions. Try increasing the value of the MinRecursion option. If value of integral may be 0, specify a finite value for the AccuracyGoal option.  Power::infy: Infinite expression 1/0. encountered.  NIntegrate::izero: Integral and error estimates are 0 on all integration subregions. Try increasing the value of the MinRecursion option. If value of integral may be 0, specify a finite value for the AccuracyGoal option.  General::stop: Further output of NIntegrate::izero will be suppressed during this calculation.  Power::infy: Infinite expression 1/0. encountered.  General::stop: Further output of Power::infy will be suppressed during this calculation.  FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.  FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.  FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.  General::stop: Further output of FindRoot::lstol will be suppressed during this calculation.  FindRoot::jsing: Encountered a singular Jacobian at the point {zl} = {0.825567}. Try perturbing the initial point(s).  FindRoot::jsing: Encountered a singular Jacobian at the point {zl} = {0.825567}. Try perturbing the initial point(s).  FindRoot::jsing: Encountered a singular Jacobian at the point {zl} = {0.825567}. Try perturbing the initial point(s).  General::stop: Further output of FindRoot::jsing will be suppressed during this calculation.  In[61]:= functionSLD[-17.5] // Quiet  Out[61]= \$  Aborted 

I expect functionSL to have an extremum for at least two values (looking only at t<0) so that functionSLD has at least two roots, I think I got one root at t=0 which is clear in the plot of $$\frac{dS}{dt}$$ and it really confirms my expectations, the other is located somewhere else (it seems clear in the plot).

You can see that at t=0, functionsSLD = -3.58024*10^-12 which is essentially zero, as t goes to lower values functionSLD rises and then goes down again and it looks like it is going to be essentially zero again but as you can see at t=-17.5 I aborted the calculation (in the sample values of functionSLD) because it just takes so long and it seems like there is a problem.

In the end, what I want to see is a plot of functionSLD[t] vs. t ($$\frac{dS}{dt}$$).

I would also like somebody to check my NIntegrate Rules if there is something wrong with it, or can it be improved. I added a singularity handler because an error occurred which I pasted in the above sample values code.