0

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]

MarcoB
  • 67,153
  • 18
  • 91
  • 189

2 Answers2

0

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

Daniel Huber
  • 51,463
  • 1
  • 23
  • 57
0
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

Daniel Huber
  • 51,463
  • 1
  • 23
  • 57