Karim Belabas on Fri, 18 Nov 2022 02:41:48 +0100


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

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


* 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]]

Cheers,

    K.B.
--
Karim Belabas  /  U. Bordeaux,  vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/
`