0
$\begingroup$

How to construct the direction field for y' = y -cos π/2 x I have tried the Plot function Plot[Derivative[1][y][x] == y[x] - (cos π x)/2, y[x], x]

$\endgroup$
0
0
$\begingroup$
eq = {y'[x] == y[x] - Cos[Pi x/2], y[2] == 2};
fun[x_] = y[x] /. DSolve[eq, y, {x, 0, 4}][[1]];
Show[{
  VectorPlot[{1, y - Cos[Pi x/2]}, {x, -1, 2}, {y, -1, 2}],
  Plot[fun[x], {x, -1, 2}, PlotRange -> All]
  }]

enter image description here

$\endgroup$
0
$\begingroup$

You can get the direction field by: {1,y'}, that is, at point {x,y} the increase in y is y'[x] if x increases by 1:

VectorPlot[{1, y - Cos[ Pi x/2]}, {x, -1, 1}, {y, -1, 1}]

enter image description here

$\endgroup$
1
  • $\begingroup$ good! how to highlight the curve that satisfies y (2)= 2 on the same grid! $\endgroup$ Dec 17 '20 at 21:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.