# Plot the output of DSolve [duplicate]

I need to plot the output of DSolve. How should I proceed?

{{a[t] -> InverseFunction[E^(2 C[1])ArcTanh[Sqrt[#1]/Sqrt[E^(2 C[1]) + #1]] - Sqrt[#1] Sqrt[E^(2 C[1]) + #1] &][t]}

We can set E^{2C[1]} to one for now for simplicity.

For C[1]=1

sol = InverseFunction[
E^(2 C[1]) ArcTanh[Sqrt[#1]/Sqrt[E^(2 C[1]) + #1]] -
Sqrt[#1] Sqrt[E^(2 C[1]) + #1] &][t] /. C[1] -> 1


It is complex valued. So you can only plot the real part or the imaginary part or absolute value.

 Plot[Re[sol/.t->tt],{tt,-10,10}]


Plot[Im[sol /. t -> tt], {tt, -10, 10}]


Plot[Abs[sol/.t->tt],{tt,-10,10}]


You can also use

ReImPlot[sol/.t->tt,{tt,-10,10}]


Let us assign the solution to a variable first to make it easier to use:

sol = {a[t] -> InverseFunction[E^(2 C[1])ArcTanh[Sqrt[#1]/Sqrt[E^(2 C[1])
+ #1]] -  Sqrt[#1] Sqrt[E^(2 C[1]) + #1] &][t]}


You can directly assign this value from the DSolve expression as well as in:

sol = DSolve[ ... ]


Note that there was a stray { in the code provided. Note that if your solution consists of multiple lists of a[t] values, this may become a little more complicated but the overall idea should remain the same.

Now Plot the solved for function with the given information (C[1] -> 0, which makes the exponential term as a whole go to 1):

Plot[a[t] /. (sol /. C[1]->0), {t, -10, 10}]


Note that we substitute in C[1]->0 into the solution first and then use that solution to get a[t]. Also note that due to the naming a[t] in the pattern in sol that we cannot use some other variable without going through some additional substitutions.

The graph disappears at $$t=0$$. Examining a[1] requires us to use those additional substitutions, but quickly reveals what's going on:

(a[t] /. (sol /. C[1] -> 0)) /. t -> 1


-0.868... - 0.847... I

In both cases I use a pretty specific order of substitution that in my experience works most reliably with these sorts of solution sets. The most important matter here is that if the substitution t->1 affects the group C[1] -> 0, then it won't do anything because there's no t in that group. It needs to catch all of the t values we need to substitute, so it needs to go on the outermost side.

In any case, the reason the graph disappears at $$t=0$$ is because for positive $$t$$ values the function has an imaginary component. We can split that out as follows:

Plot[Evaluate[{Re[a[t]], Im[a[t]]} /. (sol /. (C[1] -> 0))],
{t, -10, 10}]


The use of Evaluate here causes the table to get split up before it gets to Plot, so the lines have different colors. It is not strictly necessary otherwise. Re and Im grab the real and imaginary components.

It is possible that your full solution set has at least 1 or 2 other possible a[t] functions, since this looks similar to how a quadratic or a cubic would split around the roots of unity. If so, one of them may be real for some or all positive $$t$$ values.