Bill Allombert on Sun, 20 Nov 2022 10:50:05 +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 Sat, Nov 19, 2022 at 09:52:32AM -0800, Thomas D. Dean wrote:
> On 11/19/22 04:58, Charles Greathouse wrote:
> 
> > 
> >     ? A     = [a,b;c,d];
> >     ? basis = [matrix(2,2,k,l,k==i&&l==j)|i<-[1..2];j<-[1..2]]
> >     %2 = [[1,0;0,0],[0,1;0,0],[0,0;1,0],[0,0;0,1]]
> >     ? C     = [A * B - B * A  | B<-basis]
> >     %3 = [[0,-b;c,0],[-c,a-d;0,c],[b,0;-a+d,-b],[0,b;-c,0]]
> >     ? D     = Mat([concat(Vec(c))  | c<-C]~)
> >     %4 = [0,-c,b,0;-b,a-d,0,b;c,0,-a+d,-c;0,c,-b,0]
> >     ? matker(D)
> >     %5 = [1/c*a-d/c,1;1/c*b,0;1,0;0,1]
> > 
> >     Cheers,
> >     Bill.
> > 
> 
> Ubuntu 20.04 latest gp.
> 
> I get an error with this code. The value of D is not the same order and is
> enclosed with brackets.

Ah sorry, there is a misplaced ~, try this one.

A     = [a,b;c,d];
basis = [matrix(2,2,k,l,k==i&&l==j)|i<-[1..2];j<-[1..2]]
C     = [A * B - B * A  | B<-basis]
D     = Mat([concat(Vec(c~))  | c<-C])
matker(D)

Cheers,
Bill