I am trying to plot the derivative of function g[x]
below where g[x]
is defined as the root of another equation. However, I am getting nonsensical answers for the derivative.
Any advice would be much appreciated!
Simplified code is below:
jRa[T3_] := 10^-5/(1 + 5*10^-8/T3)
jRb[x_, T3_] :=
x*1.3*10^-4/(10^-4 +
x*(1 + 10^-6/(10^-5 - T3)))
g[x_?NumericQ] := (T3 /.
FindRoot[{jRa[T3] == jRb[x, T3]}, {{T3, 10^-7}},
MaxIterations -> 1000])/Ttot
s1 = Plot[(g[x]), {x, 10^-7, 2*10^-5}, PlotRange -> All]
s2 = Plot[g'[x], {x, 10^-7, 2*10^-5}, PlotRange -> All]
g'[.9*10^-5]
Ttot
(I know that this is just a small oversight). $\endgroup$g'[x]
, is clearly incorrect and it's negative where it should be positive. It may be because of the unusual magnitude of the numbers you used, but it's clearly incorrect on my machine. TheND
function from the<<NumericalCalculus`
package is usually much more reliable. However, in this case it also gives a wrong result on my machine! I do not know why. Looks like a bug to me. $\endgroup$Ttot = 1.0
) $\endgroup$