English: A vector field
in the plane. The function
satisfies
, which satisfies the LaSalle's invariance principle, showing that the origin is asymptotically stable.
Plotted in Julia by the following code.
```julia
using CairoMakie, LinearAlgebra
- Lyapunov function example from https://web.archive.org/web/20190714024047/http://www.math.byu.edu/~grant/courses/m634/f99/lec23.pdf
df(x, y) = [-y - x^3; x^5]
lyapf(x, y) = x^6 + 3y^2
using Interact
- define Figure
scene = Figure(resolution = (1600, 3200))
Axis(scene[1,1], backgroundcolor = "black")
- define (x, y) points for plotting
xmin, xmax, xres = -1, 1, 41
ymin, ymax, yres = -1, 1, 41
x = range(xmin, stop = xmax, length = xres)
y = range(ymin, stop = ymax, length = yres)
xs = repeat(x, outer=length(y))
ys = repeat(y, inner=length(x))
- plot vector field
vectors = df.(xs, ys)
us = map((x) -> x[1], vectors)
vs = map((x) -> x[2], vectors)
us /= 5
vs /= 5
n = vec(norm.(vectors))
n /= maximum(n) / 10
arrows!(xs, ys, us, vs, arrowsize = n, linecolor=n, arrowcolor = :white)
Axis(scene[2,1], backgroundcolor = "black")
- plot contour of Lyapunov function for the vector field
arrows!(xs, ys, us, vs, arrowsize = n, linecolor=n, arrowcolor = :white)
- plot contour of Lyapunov function for the vector field
zs = lyapf.(xs, ys)
Makie.contour!(xs, ys, zs, levels = 30, linewidth = 2, colormap = :grayC)
- display plot
- scene
save("LaSalle.png", scene)
```