Ordinary differential equations: Slope field and solution curves with R
Drawing a slope field [R task]
We consider the differential equation
- 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 , 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