Investigation of the field of directions and isoclines of a differential equation
Introduction
Differential equations are a powerful tool for describing dynamic processes in nature, technology, and economics. However, their analytical solution is not always possible, and often not necessary to understand the overall behavior of the system. In such cases, qualitative analysis methods come to the rescue, among which visualization of the fields of directions and isoclines occupies a special place.
In this example, we examine the equation using modern computing tools of the Julia language. We will not only build a mathematical model, but also create a visual visualization that allows us to intuitively understand the structure of solutions to this equation. Using the Plots libraries.jl and DifferentialEquations.jl demonstrates how modern computing technologies make complex mathematical concepts accessible and visual.
We will attach the necessary libraries.
import Pkg; Pkg.add("DifferentialEquations")
using DifferentialEquations, LinearAlgebra
Definition of the function and initial conditions
Let's define the isocline function. This simple function defines a family of isocline curves of constant slope.
For the equation Isoclines are parabolas offset vertically.
функция_изоклины(x, R) = x.^2 .+ R
Setting the boundaries of the plot area along the axes and .
We will also define the range of the parameter for isoclines, this will create a diverse family of curves.
x_мин = -4.0
x_макс = 4.0
y_мин = -4.0
y_макс = 4.0
R_мин = -2
R_макс = 2
Isoclines
Let's create the main canvas for our graph with convenient dimensions.
основной_график = plot(size=(800, 600), grid=true, legend=:best);
In this cycle, we will create the family of isoclines itself - each line corresponds to its own value. .
The denser the isoclines, the faster the slope of the solution changes in this area.
for R_текущее in R_мин:1:R_макс
x_значения = range(x_мин, x_макс, length=100)
y_значения = функция_изоклины(x_значения, R_текущее)
plot!(основной_график, x_значения, y_значения, linewidth=2, label="R = $R_текущее")
end
Let's form a uniform grid of points along the axes and for building vectors.
These points will become the starting coordinates for the directions field.
сетка_x = range(x_мин, x_макс, length=15)
сетка_y = range(y_мин, y_макс, length=15)
The directions field
We will prepare arrays for storing vector data.
Each vector needs a starting point and the components of the direction .
x_векторы = Float64[]
y_векторы = Float64[]
u_компоненты = Float64[]
v_компоненты = Float64[]
In this double loop, we calculate the direction of each vector of the field.
for x in сетка_x
for y in сетка_y
производная_y = y - x^2
производная_x = 1.0
длина = norm([производная_x, производная_y])
if длина > 0
push!(x_векторы, x)
push!(y_векторы, y)
push!(u_компоненты, 0.4производная_x/длина)
push!(v_компоненты, 0.4производная_y/длина)
end
end
end
Let's add the directions field to our graph with red lines.
quiver!(основной_график, x_векторы, y_векторы, quiver=(u_компоненты, v_компоненты),
color=:red, linewidth=1.5, label="The directions field");
The differential equation
Let's define a differential system - this is the core of our task.
The function returns the derivative at a point , defining the local behavior of solutions.
function система_ОДУ(переменные, параметры, x)
y = переменные[1]
return [y - x^2]
end
Let's define the initial conditions for integral curves.
For a better visual difference, we will assign each solution its own line color.
начальные_условия = [-3.0, -1.0, 1.0, 3.0]
цвета = [:green, :magenta, :cyan, :black]
стили_линий = [:dash, :dash, :dash, :dash]
Solution and visualization
Let's numerically solve the ODE for each initial condition.
High computational accuracy guarantees smooth and accurate integral curves.
for (индекс, y_начальное) in enumerate(начальные_условия)
начальный_вектор = [y_начальное]
интервал_времени = (x_мин, x_макс)
задача = ODEProblem(система_ОДУ, начальный_вектор, интервал_времени)
решение = solve(задача, Tsit5(), reltol=1e-8, abstol=1e-8)
end
Let's build the resulting graph.
xlabel!("x")
ylabel!("y")
title!("Поле направлений и изоклины уравнения dy/dx = y - x²")
xlims!(x_мин - 0.5, x_макс + 0.5)
ylims!(y_мин - 0.5, y_макс + 0.5)
plot!(top_margin = 8Plots.mm)
display(основной_график)
The final result shows the beauty and structure of the differential equation.
Conclusion
The conducted research clearly demonstrates visual methods in the analysis of differential equations. The constructed field of directions, combined with the family of isoclines, forms a kind of "terrain map" that allows predicting the behavior of solutions without explicitly finding them. The integral curves calculated by numerical methods confirm the correctness of the qualitative analysis and show how different initial conditions lead to different trajectories in the phase space.
Of particular value is the practical implementation of the method in the Engee environment, which combines computational efficiency and simplicity of Julia syntax. The resulting visualization serves as an excellent educational material, demonstrating the unity of analytical and numerical methods in modern mathematics. This approach opens up new possibilities for presenting complex mathematical concepts and conducting research in various scientific fields where differential equations serve as the main modeling tool.
