Hongyi Zhao on Fri, 18 Nov 2022 03:37:49 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Obtaining the coefficient matrix of multivariable homogeneous linear equation system.


On Fri, Nov 18, 2022 at 9:40 AM Karim Belabas
<Karim.Belabas@math.u-bordeaux.fr> wrote:
>
> * Hongyi Zhao [2022-11-18 02:21]:
> > Hi here,
> >
> > I've a multivariable homogeneous linear equation system as shown below:
> >
> > $ gp
> > ? trmat=[x1,x2;x3,x4];A=[a,b;c,d];
> > ? A * trmat - trmat *A
> > %50 =
> > [                 x3*b - x2*c x2*a + ((-x1 + x4)*b - x2*d)]
> >
> > [-x3*a + ((x1 - x4)*c + x3*d)                 -x3*b + x2*c]
> >
> > Where, trmat=[x1,x2;x3,x4] corresponds to the variables. My aim is to
> > obtain the corresponding coefficient matrix as follows:
> >
> > [[0, -c, b, 0], [-b, a - d, 0, b], [c, 0, -a + d, -c], [0, c, -b, 0]]
> >
> > Is there any way to achieve this goal?
>
>
> Here's a basic idea
>
>   SUBST(e) = vector(4, i, substvec(e, [x1,x2,x3,x4], vector(4,j,i==j)));
>
> Then:
>
>   ?  m = A * trmat - trmat * A;
>   ? [ SUBST(m[i,j]) | i<-[1,2]; j<-[1,2] ]
>   %2 = [[0, -c, b, 0], [-b, a - d, 0, b], [c, 0, -a + d, -c], [0, c, -b, 0]]

Thank you for your tip and help. It does the trick.

But I still have some further minor questions:

1. How to reshape the above output so that it can be feed to matker
directly, as follows:

? matker([0, -c, b, 0;-b, a - d, 0, b;c, 0, -a + d, -c;0, c, -b, 0])
%6 =
[1/c*a - d/c 1]

[    -1/-c*b 0]

[          1 0]

[          0 1]


2. How to refer the previous variables without explicitly using their
names, say, mimic the %, %%, etc. in Wolfram language?

> Cheers,
>
>     K.B.

Best,
Zhao