Direction field
A direction field is used for the graphic determination of approximate solutions of a differential equation .
The solutions of a differential equation of the first order of a scalar function y (x) can be drawn in a 2-dimensional space with x in the horizontal and y in the vertical direction. Possible solutions are functions y (x), which are drawn by curves. Sometimes it is difficult to solve the differential equation analytically. Then you can, however, the tangents of the function curves z. B. draw on a regular grid. The tangents touch the functions at the grid points.
Mathematical description
A direction field of a differential equation (first order) is created by assigning a vector with a slope to each point in the plane . This indicates the direction in which the graphs of possible solutions of the differential equation that go through the point run.
In practical terms, this means that arbitrary points can be selected in a coordinate system and that the slope is calculated by inserting it into the differential equation. (Because the derivative of corresponds to the slope of the function.)
The equation of the individual tangent segments of the length is :
The isoclines , given by the equation , i.e. the lines with the same gradient, are often helpful in the graphic representation .
example
The differential equation has the slope value 0 in all points , since this is given by . In the point it is then in the point . With enough points you get a directional field in which multitudes of possible solutions can be rudimentarily made visible through their functional tangents.
Octave script for direction field
The script direction field.m is written for GNU Octave and draws a direction field for DGL , a differential equation of the first degree.
% Inhalt des Files ''richtungsfeld.m''
function richtungsfeld(dgl)
% dgl ist die erste Ableitung von y nach x und ist i.A. eine Funktion von x und y
% Ausschnitt und Abstand zwischen den Vektoren
y = -5:.5:5; x = -5:.5:5;
for y_n = 1:length(y)
for x_n = 1:length(x)
len = sqrt( dgl(y(y_n), x(x_n))^2 + 1 ); % Länge des Vektors für Normierung
dx(y_n,x_n) = 1 / len; % Länge des Vektors entlang der Abszisse
dy(y_n,x_n) = dgl(y(y_n), x(x_n)) / len; % Länge des Vektors entlang der Ordinate
end
end
h=quiver(x, y, dx, dy,0.5,"r","linewidth",1); % Vektoren zeichnen
set (h, "maxheadsize", 0.1);
xlabel ("x");
ylabel("y");
print('field.svg', '-dsvg') % Plot als svg-Datei exportieren
% Ende des Files
- Now call up the file as follows within an Octave session:
source("richtungsfeld.m")
dgl = @(y, x) y-x % Funktionsdefinition
richtungsfeld(dgl)
See also
literature
- W. Walter: Ordinary Differential Equations: An Introduction. 7th edition. Springer, Berlin 2000, ISBN 3-540-67642-2
- F. Reinhardt, H. Soeder: dtv-Atlas Mathematik. Volume 2. 11th edition. Deutscher Taschenbuch Verlag, 1998, ISBN 3-423-03008-9