# Plotting the solution of differential equations [closed]

I want to plot solution of differential equations. I can get real values out of my function, and get no errors from the Plot, but also no curve shows up.

Assume initial condition θ = π/6, θ' = 1.

Here is my code:

Clearall

T[t_] =
ExpToTrig[
DSolve[
{θ''[t] + 2 g θ[t]/(3(R - ρ)) == 0 /. {R -> 1, ρ -> 2, g -> 9.81},
θ == 0.52, θ' == 1}, θ[t], t]]

T1[t_] =
NDSolve[
{θ''[t] + 2 g θ[t]/(3*(R - ρ)  == 0 /. {R -> 1, ρ -> 2, g -> 9.81 },
θ == π/6, θ' == 1}, θ[t], {t, 0, 10}]

T[t]
Plot[T[t], {t, 0.1, 1}]
T
T1


Any help would be appreciated.

## closed as off-topic by m_goldberg, xzczd, Henrik Schumacher, Öskå, MarcoBFeb 11 at 0:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, xzczd, Henrik Schumacher, Öskå, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.

• Try these syntax fixes T[t_] =ExpToTrig[θ[t]/.DSolve[{θ''[t] + 2*g*θ[t]/(3*(R - ρ)) ==0 /. {R->1, ρ->2, g->9.81 },θ==0.52,θ' == 1}, θ[t], t][]]; T1[t_] = θ[t]/.NDSolve[{θ''[t] + 2*g*θ[t]/(3*(R - ρ))==0/.{R->1, ρ->2, g->9.81 }, θ == \[Pi]/6, θ' == 1}, θ[t], {t, 0, 10}][]; and then you can use your last four lines T[t], Plot[... – Bill Feb 10 at 3:52
• Be aware that Clearall standing alone accomplishes nothing. It is not a command. It is a symbol naming a function. You must give it arguments. Hower, in your situation Clear is more appropriate. It not a command either, so give it arguments. – m_goldberg Feb 10 at 5:57
• @m_goldberg Clearall is not even a built-in symbol. OP probably meant to use ClearAll... – Henrik Schumacher Feb 10 at 11:18
• @HenrikSchumacher. Yeah, I automatically read it as ClearAll. – m_goldberg Feb 10 at 16:06

T[t_] = ExpToTrig[
First@DSolve[{θ''[t] + 2*g*θ[t]/(3*(R - ρ)) ==
0 /. {R -> 1, ρ -> 2, g -> 9.81}, θ ==
0.52, θ' == 1}, θ[t], t]];
T1[t_] = First@
NDSolve[{θ''[t] + 2*g*θ[t]/(3*(R - ρ)) ==
0 /. {R -> 1, ρ -> 2, g -> 9.81}, θ == π/
6, θ' == 1}, θ, {t, 0, 10}];

Plot[{θ[t] /. T[t]}, {t, 0, 10}, PlotStyle -> {Red}, PlotRange -> All]

Plot[{θ[t] /. T1[t]}, {t, 0, 10}, PlotStyle -> {Red}, PlotRange -> All]

• +1 Recommend that you use exact numbers for the parameters and in the first plot set the WorkingPrecision. The plot will be much smoother. – Bob Hanlon Feb 10 at 4:40