# Substituting solutions of a differential equation into another function

I have a rather complicated differential equation, $$\ddot \theta=\frac{ml(g-l\dot\theta^2 \cos \theta)(\sin\theta - \mu_k \cos\theta)}{I+ml^2\sin\theta(\sin\theta-\mu_k \cos \theta)}$$ I have managed to solve this equation using DSolve. Now, I want to substitute the solution $$\theta [t]$$ into another function: $$F[t]=m[l(\ddot\theta \cos \theta-\dot\theta^2 \sin\theta)]$$. However, I cannot do it.

The code is attached:

sol=DSolve[θ''[t]==(m l (g - Ι (θ'[t])^2 Cos[θ[t]])(Sin [θ[t]]-μk Cos[θ[t]]))/(Ι + m l^2 Sin[θ[t]](Sin[θ[t]]-μk Cos[θ[t]])), θ[t], t]

Ak = sol[[1]]

j = sol[[2]]

DSolve [{F[t] ==m l (θ''[t] Cos[θ[t]]-θ[t]'^2 Sin[θ[t]])}/.k,F[t],t]

DSolve [{F[t] ==m l (θ''[t] Cos[θ[t]]-θ[t]'^2 Sin[θ[t]])}/.j,F[t],t]

DSolve[{n[t]- m g==-m l(θ''[t]Sin[θ[t]]+θ'^2 Cos[θ[t]]) }/.k, n[t], t]

DSolve[{n[t]- m g==-m l(θ''[t] Sin[θ[t]]+θ'^2 Cos[θ[t]]) }/.j, n[t], t]

m=0.03517;
l=0.0279;
g=9.81;
Ι=10^-3;
μk=0.1827;
DEFricitonk = NDSolve[{F[t] ==m l (θ''[t] Cos[θ[t]]-θ[t]'^2 Sin[θ[t]]), θ[0]== π/2,θ'[0]==0, F[0]==0}/.k,F,{t,0,5}]

DEFrictionj= NDSolve[{F[t] ==m l (θ''[t] Cos[θ[t]]-θ[t]'^2 Sin[θ[t]]), θ[0]== π/2,θ'[0]==0, F[0]==0}/.j,F,{t,0,5}]

DENormalk= NDSolve[{n[t]- m g==-m l(θ''[t]Sin[θ[t]]+θ'^2 Cos[θ[t]]) , θ[0]== π/2,θ'[0]==0, F[0]==0}/.k,n,{t,0,5}]

DENormalj= NDSolve[{n[t]- m g==-m l(θ''[t]Sin[θ[t]]+θ'^2 Cos[θ[t]]) , θ[0]== π/2,θ'[0]==0, F[0]==0}/.j,n,{t,0,5}]


Please send help. Thank you so much.

• You question concerns one ode and one substitution. And your ?minimal? working example consists out of 9 (N)DSolve commands? Nov 11, 2020 at 15:44
• Consider whether DSolveValue or NDSolveValue might give answers in a more convenient form for you. Nov 11, 2020 at 17:09

Try

teta = DSolve[θ''[t] == (m l (g - Ι (θ'[t])^2 Cos[θ[t]]) (Sin[θ[t]] - μk Cos[θ[t]]))/(Ι +m l^2 Sin[θ[t]] (Sin[θ[ t]] - μk Cos[θ[t]]))
, θ , t][[1]] //Quiet


The subsitution into the equation F[t]==…follows using the substitution  /. θ -> teta to

F[t] == m l (θ''[t] Cos[θ[t]] - θ[t]'^2 Sin[θ[t]]) /. θ -> teta


The numerical case is solved much easier:

teta=NDSolveValue[{\[Theta]''[t] == (m l (g -i (\[Theta]'[t])^2 Cos[\[Theta][t]]) (Sin[\[Theta][t]] - \[Mu]k Cos[\[Theta][t]]))/(i +m l^2 Sin[\[Theta][t]](Sin[\[Theta][t]] - \[Mu]k Cos[\[Theta][t]]))
, \[Theta][0] == \[Pi]/2, \[Theta]'[0] == 0} /. {m -> 0.03517,l -> 0.0279,g -> 9.81,i -> 10.^-3 ,\[Mu]k -> 0.1827}, \[Theta] , {t, 0, 5}]



substitution

F[t] == m l (\[Theta]''[t] Cos[\[Theta][t]] - \[Theta][t]'^2 Sin[\[Theta][t]])
/. \[Theta] -> teta // Simplify

• For some reason I can't plot the graph Nov 12, 2020 at 1:09
• If you would specify "for some reason" one could try to help. Plot[teta[t], {t, 0, 5}] works. Nov 12, 2020 at 7:13