Ordinary differential equations: Slope field and solution curves with R
Drawing a slope field [R task]
We consider the differential equation \[\frac{\dd y}{\dd t}=1-2\,t\, y\]
- Create an R script that draws the slope field below for this differential equation by using only primitive graphical elements, such as
segments
to draw a segment (i.e., do not use theFlowField
function). - Now write an R script that randomly draws 2,000 lineal elements in the region \(0\le t\le 2, 0\le y\le 2, \), as in the figure below. Just like iron filings make the field lines of a magnetic field visible, the random drawing of lineal elements gives an impression of solution curves of the differential equation.
Unlock full access