How to get companion system in Mupad

2 views (last 30 days)
Jan Svanda
Jan Svanda on 17 Feb 2011
Hi,
I would like ask how to get the companion system of ODE in Mupad. I have system of 2 ODE's first is 2'nd order second is 1'st order.
They look like this (mupad syntax)
Lt :=[ L*diff(i_1(t),t$2)+(i_1(t)-i_2(t))/C, R*diff(i_1(t),t$1)+(i_2(t)-i_1(t))/C] ;
I know how to get the companion systems of one equation, using this function. ode::companionSystem(Equa, Var) ; If I apply this function to my system ODE's it does not function.
Could somebody give me any advice? Thanks Jan

Answers (3)

Andrew Newell
Andrew Newell on 17 Feb 2011
You could eliminate the variable i2 by solving for it in the second equation and substituting in the first. Then you have a second order ODE for i1 alone, and you can find the companion system for that.

Jan Svanda
Jan Svanda on 17 Feb 2011
Thank you for the answer.
It is true, but a would to get the companion system without eliminating. I solved it "manualy"(you cen see it below) and I would like to obtain the same solution programaticaly. Is there any smart solution :-) ?
diff(x_1(t), t)=x_2(t);
diff(x_2(t), t)=1/(L*C)*(-x_1(t)+i_2(t));
diff(x_2(t), t)=1/(R*C)*(x_1(t)-i_2(t));
A:=matrix([[0,1,0],[-1/(L*C),0,1/(L*C)],[1/(R*C),0,-1/(R*C)]])

Christopher Creutzig
Christopher Creutzig on 18 Feb 2011
I am not sure what the companion system of a system of differential equations would be, the definition does not, in my opinion, canonically generalize. However, if what you are looking for is what I would call a phase space representation (which your answer seems to suggest), you may be interested in numeric::ode2vectorfield, as in:
Lt :=[i_1'(t) = L*diff(i_1(t),t$2)+(i_1(t)-i_2(t))/C,
i_2'(t) = R*diff(i_1(t),t$1)+(i_2(t)-i_1(t))/C]:
fields := [i_1(t), i_1'(t), i_2(t)]:
fn := numeric::ode2vectorfield(
Lt . map(fields, f -> (f | t=0) = dummy), fields)[1]:
zip(map(map(fields, diff, t), rewrite, D), fn(t, i), `=`)
[i_1'(t) = i[2],
i_1''(t) = (C*i[2] - 1.0*i[1] + i[3])/(C*L),
i_2'(t) = (i[3] - 1.0*i[1] + C*R*i[2])/C]
This has some drawbacks and may not be the final solution for you:
  • numeric::ode2vectorfield will call float on its input, so you may need to work with rationalize if you want to preserve constants like ?, and use numeric::rationalize on the output, too.
  • It does not create the list fields for you, but will complain if that list does not work for the input you have.
  • numeric::ode2vectorfield will not do symbolic differentiation etc. in its computation, but instead will simply refuse to work on inputs that are not quasi-linear.
  • I may have completely misinterpreted your question and this may not at all be what you are looking for in the first place. Then again, it may be a step that can become useful in a larger program. :-)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!