Error with StateSpaceTransform: the rule based transformation must be of length 2

I would like to perform a change of variables on the following dynamics system:

system = NonlinearStateSpaceModel[{{y1'[t] == y2[t],
y2'[t] == -theta[t]^2 y1[t] +
theta'[t] y2[t]/theta[t]}, {alpha1 y1[t] + alpha2 y2[t]}}, {y1[
t], y2[t]}, {}]


The change of variables would be: y2[t] -> theta[t] y3[t]. While I could easily see what would be the outcome by hand, I don't see why this command would not return anything with Mathematica:

StateSpaceTransform[system, {{y2[t] -> theta[t] y3[t]}, {y3[t] ->
y2[t]/theta[t]}}]


The error I receive is meaningless in my honest point of view since:

Length@ {{y2[t] -> theta[t] y3[t]}, {y3[t] ->
y2[t]/theta[t]}}


returns 2.

• It's Length /@ that must give {2, 2}. It wants 2 transformations going both ways. Since you have to put something in for a second transformation in each, how about putting y1[t] -> y1[t] into both of them? – LouisB Jul 23 '19 at 9:16
• Yes you're right. I added the two dummy transformations but it seams to say that the system is not a valid nonlinear state space model... I guess Mathematica doesn't like the time varying parameters – Mirko Aveta Jul 23 '19 at 9:45
• If MMA doesn't like time varying parameters, make them state variables. Maybe it's the $\frac{d\theta}{dt}$ that's confusing things. What governs the time evolution of $\theta$ anyway? – LouisB Jul 23 '19 at 10:24
• It is unknown. I was just willing to see the pretty change of variables. It's a petty that TV systems are not treated by Mathematica. Most industrial applications are modeled as such. – Mirko Aveta Jul 23 '19 at 11:18

(Several points that make it too long for a comment.)

• As @LouisB points out in the comments, StateSpaceTrasform is expecting a transformation of dimension {2, 2}.

• The usage of NonlinearStateSpaceModel should be something as shown below. What you have is GIGO. (Just try StateSpaceModel[system].)

eqns = {D[y1[t], t] == y2[t],
D[y2[t], t] == -theta[t]^2 y1[t] + D[theta[t], t] y2[t]/theta[t]};

NonlinearStateSpaceModel[eqns, {y1[t], y2[t], theta[t]}, {},
{alpha1 y1[t] + alpha2 y2[t]}, t]

• Next, what you want as your state space is not clear. What is the initial state-space? $$\{y1, y2\}$$ or $$\{y1, y2, theta\}$$. When you invoke StateSpaceTransform what do you want your final state-space to be?

• And finally, the system you have is problematic. This is related to the point above. You need to have a well-defined state space for any computations to make sense.

NDSolve[Join[eqns, {y1[0]==1,y2[0]==0,theta[0]==0.01}],{y1,y2},{t,0,1}]


returns unevaluated with the message

NDSolve::underdet: There are more dependent variables, {theta[t],y1[t],y2[t]}, than equations, so the system is underdetermined.

Update

Convert to state-space form. To do this we need to briefly consider the time-varying parameter as constant.

system = With[{tempRules = {theta[t] -> theta, theta'[t] -> thetaD}},
NonlinearStateSpaceModel[eqns /. tempRules,
{y1[t], y2[t]}, {}, {alpha1 y1[t] + alpha2 y2[t]}, t] /. Reverse /@ tempRules]


Then perform the state-space transformation.

StateSpaceTransform[system, {{1, 0}, {0, theta[t]}}]


• Hi Suba! My initial state-space is {y1,y2} as I mentioned above, so I expect the new state space to be {y1,y3}. In my point of view theta[t] is not a state, it is a time-varying quantity making the system non-autonomous. I do not want to define it with a specific function. – Mirko Aveta Jul 24 '19 at 7:40
• Hi Mirko. Currently, when converting from a differential or difference equation the time dependent parameters need to be either a state or an input variable. You can circumvent this by temporarily assigning them to constants when the conversion to state-space form happens. Pls see my update. – Suba Thomas Jul 24 '19 at 13:38
• The problem with this convention is that you miss the derivatives when converting: I I do the derivative of y2 I would have to see theta' y3+theta y3'. This seams to be missing with the assignment you're suggesting. I would expect from the change of variables a real Jordan form. – Mirko Aveta Jul 25 '19 at 11:27
• I see. Yes. It is a bug that needs to be fixed. – Suba Thomas Jul 25 '19 at 13:56
• The fix will be in the next release. Thanks. – Suba Thomas Aug 1 '19 at 16:52