Slope field


The solutions of a first-order differential equation of a scalar function y can be drawn in a 2-dimensional space with the x in horizontal and y in vertical direction. Possible solutions are functions y drawn as solid curves. Sometimes it is too cumbersome solving the differential equation analytically. Then one can still draw the tangents of the function curves e.g. on a regular grid. The tangents are touching the functions at the grid points. However, the direction field is rather agnostic about chaotic aspects of the differential equation.

Definition

Standard case

The slope field can be defined for the following type of differential equations
which can be interpreted geometrically as giving the slope of the tangent to the graph of the differential equation's solution at each point as a function of the point coordinates.
It can be viewed as a creative way to plot a real-valued function of two real variables as a planar picture. Specifically, for a given pair, a vector with the components is drawn at the point on the -plane. Sometimes, the vector is normalized to make the plot better looking for a human eye. A set of pairs making a rectangular grid is typically used for the drawing.
An isocline is often used to supplement the slope field. In an equation of the form, the isocline is a line in the -plane obtained by setting equal to a constant.

General case of a system of differential equations

Given a system of differential equations,
the slope field is an array of slope marks in the phase space. Each slope mark is centered at a point and is parallel to the vector
The number, position, and length of the slope marks can be arbitrary. The positions are usually chosen such that the points make a uniform grid. The standard case, described above, represents. The general case of the slope field for systems of differential equations is not easy to visualize for.

General application

With computers, complicated slope fields can be quickly made without tedium, and so an only recently practical application is to use them merely to get the feel for what a solution should be before an explicit general solution is sought. Of course, computers can also just solve for one, if it exists.
If there is no explicit general solution, computers can use slope fields to numerically find graphical solutions. Examples of such routines are Euler's method, or better, the Runge–Kutta methods.

Software for plotting slope fields

Different software packages can plot slope fields.

Direction field code in [GNU Octave]/[MATLAB]


funn = @y-x; % function f=y-x
=meshgrid; % intervals for x and y
slopes=funn; % matrix of slope values
dy=slopes./sqrt; % normalize the line element...
dx=ones./sqrt; %...magnitudes for dy and dx
h=quiver; % plot the direction field
set ; % alter head size

Example code for Maxima">Maxima (software)">Maxima

/* field for y'=xy */
plotdf;

Example code for [Mathematica]


VectorPlot

Example code for [SageMath]https://doc.sagemath.org/html/en/reference/plotting/sage/plot/plot_field.html


var
plot_slope_field, )

Examples


Image:Slope_field_1.svg|Slope field
Image:Slope_field_with_integral_curves_1.svg|Integral curves
image:Isocline_3.png|Isoclines, slope field, and some solution curves