%
% Symbolic code for DFIM
%
syms lss lsw msw lrr lrw mrw lsr msr np th m3t2 cv l2ss ...
     l2sr l2rr is2 isa isb ish ir2 irx iry irh tm lslrt real
%
% Original model
%
a=2*pi/3;
lss=[lsw msw msw;msw lsw msw;msw msw lsw];
lrr=[lrw mrw mrw;mrw lrw mrw;mrw mrw lrw];
lsr=msr*[cos(np*th) cos(np*th+a) cos(np*th-a); ...
    cos(np*th-a) cos(np*th) cos(np*th+a);
    cos(np*th+a) cos(np*th-a) cos(np*th)];
%
% 2-phase equivalent inductance matrices
%
m3to2=cv*[1 -1/2 -1/2;0 sqrt(3)/2 -sqrt(3)/2;1/sqrt(2) ...
    1/sqrt(2) 1/sqrt(2)];
l2ss=simplify(m3to2*lss*inv(m3to2)) 
l2sr=simplify(m3to2*lsr*inv(m3to2)) 
l2rr=simplify(m3to2*lrr*inv(m3to2)) 
%
% 2-phase equivalent torque
%
is2=[isa;isb;ish];ir2=[irx;iry;irh];
tm=simplify(is2'*inv(m3to2)'*diff(lsr,th)*inv(m3to2)*ir2)
% 
% Proof of Fact 2
%
lsrlsrt=simplify(lsr*lsr')