# Get the derivative function plot from a NDSolve solution

I been trying to plot the derivative function of j[t], being j'[t]. Here a look to the code. I would appreciate your help. Thank you

g = 9.81; ve = 20.47; mr = 0.3; mw = 0.75; b = 0.0024052;
J = NDSolve[{j'[
t] == -(g - (mw*ve^2*Exp[-ve*t])/(mr +
mw*Exp[-ve*t])) + (mw*ve*Exp[-ve*t])/(mr + mw*Exp[-ve*t])*
j[t] - (b/(mr + mw*Exp[-ve*t]))*j[t]^2, j == 0}, j[t], {t, 0,
5}]

Plot[j[t]/.J , {t, 0,10}, PlotRange -> {-60,60}]

Plot[Evaluate[j'[t]/.J], {t, 0,10}, PlotRange -> {-100,100}]

• dj=D[j[t]/.J,t]; Plot[dj,{t,0,10},PlotRange->All] seems to work just fine with no other changes – Bill Aug 12 at 21:00
• Great, it seems to work fine, however and as other question, how do you do it in order to get the integrated function of j[t]? @Bill – Luis Aug 12 at 22:11
• s=Integrate[(j[t]/.J)[],{t,0,x}]; Plot[s,{x,0,8}] seems to work just fine. Test all this very carefully to make certain that it is correct. – Bill Aug 13 at 1:38
• You can integrate an InterpolatingFunction directly: Integrate[j[t] /. First[J], t] – Michael E2 Aug 13 at 14:11

Try NDSolveValue

J = NDSolveValue[{j'[t] == -(g - (mw*ve^2*Exp[-ve*t])/(mr +mw*Exp[-ve*t])) + (mw*ve*Exp[-ve*t])/(mr + mw*Exp[-ve*t])*j[t] - (b/(mr + mw*Exp[-ve*t]))*j[t]^2, j == 0}, j, {t,0,5}]

Plot[ J'[t] , {t, 0,10}, PlotRange -> {-100,100}]


Request the function j, not the expression j[t], from NDSolve:

g = 9.81; ve = 20.47; mr = 0.3; mw = 0.75; b = 0.0024052;
J = NDSolve[{j'[t] == -(g - (mw*ve^2*Exp[-ve*t])/(mr +
mw*Exp[-ve*t])) + (mw*ve*Exp[-ve*t])/(mr + mw*Exp[-ve*t])*
j[t] - (b/(mr + mw*Exp[-ve*t]))*j[t]^2, j == 0},
j, {t, 0, 5}]


Then J will have the form of (a nested list containing) a substitution rule {{j -> ...}} and it will replace j in j'[t] by the interpolating function solution NDSolve computed; this function will be automatically differentiated. The following then will work:

Plot[Evaluate[j'[t] /. J], {t, 0, 10}, PlotRange -> {-100, 100}]


Some find getting the function directly from NDSolveValue convenient (see @Ulrich's answer), which I do at times. If I need to plug j into various expressions, the substitution rule is very convenient. On the other hand, a substitution rule of the form j[t] -> ... is less convenient because it cannot be used to replace j'[t] with the solution. I never use that form.