English: A vector field
![{\displaystyle ({\dot {x}},{\dot {y}})=(-y-x^{3},x^{5})}](https://wikimedia.org/api/rest_v1/media/math/render/svg/15b41fa928515ae8c55d9ed01c6243f18c40f260)
in the plane. The function
![{\displaystyle V(x,y)=x^{6}+3y^{2}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/68a49cf3834ede44354671c14345d9100f9a195d)
satisfies
![{\displaystyle {\dot {V}}=-6x^{8}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/51997272d6e524c2fe75cfee0dacb8534dcf63ed)
, 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)
```