# Drawing Lines on Differential Equation Slope Field [closed]

I am supposed to create a detailed slope-field for x' = x + t/2

I have made a slope field using:

f[t_, x_] = x + t/2
fld = VectorPlot[{1, f[t, x]}, {t, -3, 3}, {x, -3, 3}]


I need to make three solution curves on the slope field, but I cannot figure out how to do that

• One possible approach is to make a separate plot of the solutions and then use Show[ ] to combine the slope field plot with the solution plot. – LouisB Feb 17 at 22:03

The option StreamPoints works also with VectorPlot, so you could do something like

f[t_, x_] = x + t/2
fld = VectorPlot[{1, f[t, x]}, {t, -3, 3}, {x, -3, 3},
StreamPoints -> {{{{1, .5}, Red}, Automatic}}]


Where (1,.5) above can be specific initial condition. You can more lines as needed.

fld = VectorPlot[{1, f[t, x]}, {t, -3, 3}, {x, -3, 3},
StreamPoints -> {
{{{-1, .5}, {Thick, Red}}, {{1, -.5}, {Thick, Blue}}, Automatic}
}
]


First find solution curves based on the dynamics:

ClearAll[x,dynamics,solutionCurve];
dynamics=x'[t]==x[t]+t/2;

(* based on constant *)
solutionCurve[c_]=x[t]/.First@DSolve[dynamics,x[t],t]/.C[1]->c

(* based on explicit point *)
solutionCurve[{τ_,ξ_}]=x[t]/.First@DSolve[{dynamics,x[τ]==ξ},x[t],t]


Now you can get the required plot with three solution curves by either changing the value of the constant or giving explicit points as follows:

Show[
VectorPlot[
{1,Last[dynamics]},{t,-3,3},{x[t],-3,3},
FrameLabel->{t,x[t]}
],
Plot[
solutionCurve/@{-1,{0,-(1/2)},1},
{t,-3,3},
PlotStyle->{Red,Dashed}
]
]