Skip to content

Commit

Permalink
Fix docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
michakraus committed Dec 5, 2024
1 parent a2e47ef commit dba48c7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/src/degenerate_lagrangian.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ We exemplify this with the Lotka-Volterra problem in 2d.
Before any use, we need to load `EulerLagrange`:
```@example deglag
using EulerLagrange
using LinearAlgebra
```

Next, we generate symbolic variables for a two-dimensional Lagrangian system:
Expand All @@ -51,13 +52,13 @@ sparams = symbolize(params)

Define the Hamiltonian function and the symplectic potential:
```@example deglag
H(x, params) = params.a₁ * x[1] + params.a₂ * x[2] + params.b₁ * log(x[1]) + params.b₂ * log(x[2])
ϑ(x, params) = [log(x[2]) / x[1] / 2, - log(x[1]) / x[2] / 2]
H(x, params) = params.a₁ * x[1] + params.a₂ * x[2] + params.b₁ * log(x[1]) + params.b₂ * log(x[2])
```

The Hamiltonian and the symplectic potential, evaluated on and together with the symbolic variables and parameters are used to construct a `DegenerateLagrangianSystem`:
```@example deglag
lag_sys = DegenerateLagrangianSystem(ϑ(x,sparams), H(x,sparams), t, x, v, sparams)
lag_sys = DegenerateLagrangianSystem(ϑ(x,sparams) ⋅ v, H(x,sparams), t, x, v, sparams)
```
The constructor computes the Euler-Lagrange equations and generates the corresponding Julia code.

Expand Down

0 comments on commit dba48c7

Please sign in to comment.