TwoPendula

Let A = K[t, (Subscript[L, 1]), (Subscript[L, 2]), (Subscript[m, 1]), (Subscript[m, 2]), M, g] be the commutative polynomial ring in t, (Subscript[L, 1]), (Subscript[L, 2]), (Subscript[m, 1]), (Subscript[m, 2]), M, g and let us define the Ore algebra A = A⟨∂⟩, where ∂ is differential operator defined by ∂f(t) = f'(t).

A=OreAlgebra[t,Der[t],(Subscript[L, 1]),(Subscript[L, 2]),(Subscript[m, 1]),(Subscript[m, 2]),M,g]

We consider the matrix R ∈ (A^(3×4)) given by

mat={{(Subscript[m, 1]) (Subscript[L, 1]) ((Der[t])^2),(Subscript[m, 2]) (Subscript[L, 2]) ((Der[t])^2), (M+(Subscript[m, 1])+(Subscript[m, 2]))((Der[t])^2),-1},
{(Subscript[m, 1]) ((Subscript[L, 1])^2)((Der[t])^2)-(Subscript[m, 1]) (Subscript[L, 1]) g, 0, (Subscript[m, 1]) (Subscript[L, 1]) ((Der[t])^2),0},
{0,(Subscript[m, 2]) ((Subscript[L, 2])^2) ((Der[t])^2)-(Subscript[m, 2]) (Subscript[L, 2]) g, (Subscript[m, 2]) (Subscript[L, 2]) ((Der[t])^2),0}
};
R=ToOrePolynomial[mat,A];
MatrixForm[R]

and the left A-module, finitely presented by R, is M = (A^(1×4))/(A^(1×3))R.
Let us compute the adjoint of the system

MatrixForm[Radj=Involution[R,A]]

Let us check whether or not the left A-module M is torsion-free, i.e. whether or not the system admits some autonomous elements.

MatrixForm/@({Ann,Rp,Q}=Exti[Radj,A,1])

Since the entries of the first matrix are constants (zero order operators in (Subscript[D, t])), if (Subscript[L, 1])≠0, (Subscript[L, 2])≠0,  (Subscript[m, 1])≠0, (Subscript[m, 2])≠0 then the module is torsion free. Let us now compute the obstructions for M to be projective:

Obs=ObstructionToProjectiveness[R,A]

Let us deduce the obstructions in the parameters (Subscript[L, 1]), (Subscript[L, 2]), (Subscript[m, 1]), (Subscript[m, 2]), M, g  for M to be a projective left A-module.

obs=OreIntersection[Flatten@Obs,{(Subscript[L, 1]),(Subscript[L, 2]),(Subscript[m, 1]),(Subscript[m, 2]),M,g},A]

We obtain that M is a projective left A-module, i.e. the system is flat, if and only if (Subscript[L, 1])≠0, (Subscript[L, 2])≠0, (Subscript[m, 1])≠0, (Subscript[m, 2])≠0, g≠0 and (Subscript[L, 1])≠(Subscript[L, 2]).

If (Subscript[L, 1])(Subscript[L, 2])(Subscript[m, 1])(Subscript[m, 2])g ≠ 0 and (Subscript[L, 1])≠(Subscript[L, 2]), let us compute flat output.

Factor[iOrePolynomialToNormal[obs]]

B=OreAlgebra[t,Der[t]]

T=LeftInverse[Q,B]

A flat output ξ is then defined by:

ApplyMatrix[T,{(Subscript[x, 1])[t],(Subscript[x, 2])[t],(Subscript[x, 3])[t],u[t]}][[1]]

Finally a parametrization of the flat system is defined by

Thread[{(Subscript[x, 1])[t],(Subscript[x, 2])[t],(Subscript[x, 3])[t],u[t]}->ApplyMatrix[Q,{ξ[t]}]]

If (Subscript[L, 1])=(Subscript[L, 2]), then let us compute the autonomous elements of the new system. To do that let us introduce a new Ore algebra B, defined by

B=OreAlgebra[t,Der[t],CoefficientNormal->(Expand[#/.(Subscript[L, 1])->(Subscript[L, 2])]&)]

the matrix S of differential operators given by

MatrixForm[S=ToOrePolynomial[mat,B]]

and the left B-module N finitely presented by S. Let us compute the torsion elements of N, i.e. the autnomous elements of the corresponding system.

MatrixForm[Sadj=Involution[S,B]]

MatrixForm/@({Ann,Sp,Q}=Exti[Sadj,B,1])

Since the first matrix is not identity, the system is not controllable (N is not torsion free) and we have autonomous elements, defined by the rows of Sp, namely θ, defined by

ApplyMatrix[Sp,{(Subscript[x, 1])[t],(Subscript[x, 2])[t],(Subscript[x, 3])[t],u[t]}]

For instance, θ1 satisfies the equation

Thread[ApplyMatrix[{{Ann[[1,1]]}},{θ1[t]}]==0]

Finally, this result can be obtained directly by means of the command AutonomousElements

AutonomousElements[S,{(Subscript[x, 1])[t],(Subscript[x, 2])[t],(Subscript[x, 3])[t],u[t]}, θ, B,Relations->True]

The controllable part of the system is defined by:

Thread[ApplyMatrix[Sp,{(Subscript[x, 1])[t],(Subscript[x, 2])[t],(Subscript[x, 3])[t],u[t]}]==0]

Finally let us compute a flat output of the controllable part:

ApplyMatrix[LeftInverse[Q,B],{(Subscript[x, 1])[t],(Subscript[x, 2])[t],(Subscript[x, 3])[t],u[t]}][[1]]