# Curve not shown completely after numerical resolution [duplicate]

I'm having an output problem with the following code :

fl := NDSolve[{
q''[t] == -(p'[t]^2 - (3/4) (p[t]^2 - 4)^2) q[t],
q[t] p''[t] == - 3 q'[t] p'[t] - q[t] 3 (p[t]^2 - 4) p[t],

q == 1, q' == 1, p == 1, p' == 0

}, {q, p}, {t, -50, 50},
Method -> "StiffnessSwitching"
]

T1 := (q /. fl)[][][][]
T2 := (q /. fl)[][][][]
Evaluate[p[T1] /. fl]
Evaluate[p[T2] /. fl]

Plot[Evaluate[p[t] /. fl], {t, T1, T2}, PlotRange -> All, Frame -> True]


The plot appears to show only the main part of the curve, but some parts are missing on its extremities. The evaluation at min time T1 and max time T2 shows that the curve should continue up to approx p[T1] = 16 and p[T2] = 15.68. The plot ends the curve at approx values p = 8.5 and p = 9.1. The PlotRange -> All directive doesn't seem to help here. Why ? How to show the full curve up to its extremities ?

• [][][][] can be replaced with [[1,1,1,1]] Dec 24 '16 at 19:41
• @Feyre, thanks for the trick. It works, but doesn't change my output problem.
– Cham
Dec 24 '16 at 19:43
• I found an older question on the same topic that already covers both ListLinePlot and ParametricPlot so I am marking this question as a duplicate. Dec 24 '16 at 20:17

I just found a simple trick : to use ParametricPlot, instead of Plot :

ParametricPlot[Evaluate[{t, p[t]} /. fl], {t, T1, T2}, PlotRange -> All, Frame -> True]


Now, is there a drawback with this solution ?

• I'd add , AspectRatio -> 1/GoldenRatio Dec 24 '16 at 20:06
• Off hand I don't know why ParametricPlot includes the end points and Plot does not. Clearly that helps here but conceivably that behavior may change between versions. Manual points (Table etc.) has the advantage of never changing. (And +1 for sharing your solution of course.) Dec 24 '16 at 20:06

The slope approaching T1 and T2 is extreme. By default the plot mesh doesn't get close enough to these values to show the limits. I recommend using ListLinePlot on a series of directly calculated points:

foo = First[p[t] /. fl];

ListLinePlot[
Table[{t, foo}, {t, T1, T2, (T2 - T1)/1000}]
, PlotRange -> All
, Frame -> True
] • Ufortunately, that would complicate a lot my full code (which was simplified to show the problem here). So there is no other way to get the full curve, using a standard Plot, with some options ?
– Cham
Dec 24 '16 at 20:00
• @Cham If you describe why this would complicate your full code I might be able to suggest an improvement. I'll see if I can force Plot to give you want you want however. Dec 24 '16 at 20:02
• I just found a simple trick : use ParametricPlot ! I'll post an answer ! ;-)
– Cham
Dec 24 '16 at 20:02