gtg254k
(Richard Tarbell)
1
Greetings all,
I’m working with control systems and Lyapunov function candidates. Let’s say we have a very basic system:
dX/dt = X’ = X*Y + 2X
dY/dt = Y’ = Y^2 + 3
And I have a proposed Lyapunov function candidate of:
V = X^2 + Y^2
I would like to:
-
Take an implicit time derivative of V (so as to get: dV/dt = V’ = 2 * X * X’ + 2 * Y * Y’ )
-
Plugin my system of equations for X’ and Y’ (from above) into V’
How can I do this in Mathematica?
-RT
sblinder
(S M Blinder)
2
The equation for Y is easily solved
In[36]:= DSolve[Y'[t] == Y[t]^2 + 3, Y[t], t]
Out[36]= {{Y[t] -> Sqrt[3] Tan[Sqrt[3] t + Sqrt[3] C[1]]}}
Determine C[1] using the initial condition, say Y[0].
Then solve DE for X. You can then evaluate V.
nma
(Nasser M. Abbasi)
3
I like to use little helper function called rhs, which returns the right hand side of an equation for these things.
ClearAll[x, y, v, t, eq];
rhs[eq_] := eq /. (lhs_) == (rhs_) :> rhs;
eq1 =x'[t] == x[t] y[t] + 2 x[t];
eq2 = y'[t] == y[t]^2 + 3;
eq3 = v[t] == x[t]^2 + y[t]^2;
eq4 = D[eq3, t];
which gives
v'[t] == 2 x[t] x'[t] + 2 y[t] y'[t]
and now
eq4 /. {x'[t] -> rhs[eq1], y'[t] -> rhs[eq2]}
which returns
v'[t] == 2 x[t] (2 x[t] + x[t] y[t]) + 2 y[t] (3 + y[t]^2)