In [1]:
using Flows
In [2]:
t = TimeVariable("t")
Out[2]:
In [3]:
typeof(t)
Out[3]:
In [4]:
@t_vars s r τ
Out[4]:
In [5]:
typeof(s)
Out[5]:
In [6]:
ex = TimeLinearCombination(t,1,s,-2,r,3)
Out[6]:
The internal representation of a TimeLinearCombination is a list of (TimeExpression, coefficient)-pairs:
In [7]:
ex.terms
Out[7]:
The operators +, -, * are overloaded. Therefore, the TimeLinearCombination ex from above can also be defined in the following way:
In [8]:
ex1 = t - 2s + 3r
Out[8]:
In [9]:
ex == ex1
Out[9]:
In [10]:
string(ex)
Out[10]:
In [11]:
t-2ex+11r-2(r-s)
Out[11]:
In [12]:
ex-ex
Out[12]:
In [13]:
string(ex-ex)
Out[13]:
In [14]:
ex-ex == t_zero
Out[14]:
In [15]:
typeof(t_zero)
Out[15]:
In [16]:
t_zero.terms
Out[16]:
In [17]:
ex
Out[17]:
In [18]:
coefficient(ex,s)
Out[18]:
In [19]:
substitute(ex,s,ex)
Out[19]:
In [20]:
substitute(t,s,r)
Out[20]:
In [21]:
u = SpaceVariable("u")
Out[21]:
In [22]:
@x_vars v,w
Out[22]:
In [23]:
@funs F,G,H
Out[23]:
In [24]:
typeof(G)
Out[24]:
In [25]:
ex = AutonomousFunctionExpression(F,u)
Out[25]:
In [26]:
ex1 = F(u)
Out[26]:
In [27]:
string(ex1)
Out[27]:
In [28]:
ex == ex1
Out[28]:
AutonomousFunctionExpression involving differentials:
In [29]:
ex = F(u,v)
Out[29]:
In [30]:
string(ex)
Out[30]:
In [31]:
ex = F(u,v,w)
Out[31]:
In [32]:
string(ex)
Out[32]:
In [33]:
ex = FlowExpression(F, t, u, 0) # (the last argument 0 indicates that it is a 0th derivative w.r.t. time)
Out[33]:
In [34]:
ex1 = E(F,t,u)
Out[34]:
In [35]:
ex == ex1
Out[35]:
In [36]:
string(ex)
Out[36]:
FlowExpression involving differentials:
In [37]:
ex = E(F,t,u,v)
Out[37]:
In [38]:
string(ex)
Out[38]:
In [39]:
ex = E(F,t,u,v,w)
Out[39]:
In [40]:
string(ex)
Out[40]:
In [41]:
@nonautonomous_funs(S)
Out[41]:
In [42]:
ex = S(t,u)
Out[42]:
In [43]:
string(ex)
Out[43]:
In [44]:
ex = S(2,t,u,v)
Out[44]:
In [45]:
string(ex)
Out[45]:
In [46]:
ex = -17E(F,t,u,v,w) + 2u + F(v,w)
Out[46]:
In [47]:
ex-ex
Out[47]:
In [48]:
string(ex)
Out[48]:
In [49]:
ex-ex == x_zero
Out[49]:
In [50]:
string(ex-ex)
Out[50]:
In [51]:
ex = F(G(u)) + E(F,t,u,w)
Out[51]:
In [52]:
string(ex)
Out[52]:
We form the differential of the expression ex with respect to the variable u and apply it to the expression H(v). Note that the differntial is a linear map which has to be applied to something ("the slots have to be filled").
In [53]:
differential(ex, u, H(v))
Out[53]:
In [54]:
ex = S(1,t-2s,2u+v)
Out[54]:
In [55]:
expand(differential(ex, u, w))
Out[55]:
In [56]:
ex = E(F,t-2s,u+E(G,s,v))
Out[56]:
In [57]:
t_derivative(ex, s)
Out[57]:
In [58]:
ex = S(2t,S(t,v))
Out[58]:
In [59]:
t_derivative(ex, t)
Out[59]:
In [60]:
ex = E(F,t,u,2v+3w)
Out[60]:
In [61]:
Flows.expand(ex)
Out[61]:
In [62]:
ex = G(u, v+w, v+w)
Out[62]:
In [63]:
Flows.expand(ex)
Out[63]:
In [64]:
ex = S(t,u,2v+3w)
Out[64]:
In [65]:
expand(ex)
Out[65]:
In [66]:
ex = E(F,t,u,F(u))
Out[66]:
In [67]:
reduce_order(ex)
Out[67]:
In [68]:
ex = E(F,t,u,F(u),v)
Out[68]:
In [69]:
reduce_order(ex)
Out[69]:
In [70]:
ex = E(F,t,u,F(u),v, w)
Out[70]:
In [71]:
reduce_order(ex)
Out[71]:
In [72]:
substitute(E(G,t,v), v, E(F,t,u))
Out[72]:
Commutator $[F,G]$:
In [73]:
C_FG = F(u,G(u))-G(u,F(u))
Out[73]:
Double commutator $[F,[F,G]]$ by substituting $G\to[F,G]$ in $[F,G]$:
In [74]:
expand(substitute(C_FG, G, C_FG, u))
Out[74]:
In [84]:
ex=commutator(F,G,u)
Out[84]:
In [85]:
commutator(F,G,H,u)
Out[85]:
Verify Jacobi identity $[F,[G,H]]+[H,[F,G]]+[G,[H,F]]=0$:
In [86]:
expand(commutator(F,G,H,u)+commutator(G,H,F,u)+commutator(H,F,G,u))
Out[86]:
In [89]:
ex=expand(differential(ex,u,v))
Out[89]:
In [90]:
expand(differential(ex,u,w))
Out[90]:
In [ ]: