Items tagged with matrices

I have two symmetric real matrices as below (Mt,Kk).

I multilpy them in Mt.Kk.Mt.

But the result is not symmetric.!!!!why????



restart; with(LinearAlgebra)

Error, invalid input: with expects its 1st argument, pname, to be of type {`module`, package}, but received shareman


Mt := ImportMatrix("C:/Mt.mpl"); -1; Norm(Mt-LinearAlgebra:-HermitianTranspose(Mt), 2)



Kk := ImportMatrix("C:/Kk.mpl"); -1; Norm(Kk-LinearAlgebra:-HermitianTranspose(Kk), 2)



Aa := Typesetting:-delayDotProduct(Typesetting:-delayDotProduct(Mt, Kk), Mt); -1; Norm(Aa-LinearAlgebra:-HermitianTranspose(Aa))




RTABLE(18446744074182082558, complex[8], Matrix, rectangular, Fortran_order, [], 2, 1 .. 45, 1 .. 45)
















I couldnt upload Kk.mlp and Mt.mlp so changed their extensions to mw. for using please change them to .mlp




fn1 and gn1 are the 2x2 matrices. For example


eq1:=evalm(Matrix(2,2, [1, 1, 0, 3])&*fn1+gn1)=Matrix(2,2,[0]);

eq2:=evalm(fn1+gn1)=Matrix(2,2, [0]);

how can we find fn1 and gn1 matrices?

For some strange reason my matrices are shown in a very bizarre format (see imgur link). All I want is to simply see the 6x6 matrix with the numerical values - any help would be greatly appreciated.


Is there a way to solve matrices symbolically?

an example would be A*X=B

where the answer would be 



I have tried to look for a thing in maple that will do this but so far i had no luck. Does anyone know ?

Thanks in advance

I want to analyze the runtimes on certain Linear Algebra functions in Maple, so I need a (large) set of matrices to input into these functions.

I have written the below code, which does succesfully generate a file of matrices:

The resulting file looks like:

However, I am unable to read the matrices from this file back into Maple. When using the code below, I get an error.

I think the error is that %a in fscanf scans up to the next whitespace, so the spacing in Matrix(3, 3, [[9,1,-4],[-5,6,-10],[-10,-4,-4]]) is throwing fscanf off. Do you guys know of any way I can fix this?


Or, is there a better way for me to generate these matrices so that they can be easily read into Maple? I've considered using ImportMatrix/ExportMatrix, but I believe that they only work for a single matrix, not the numerous ones that I would need. 

I have worksheet that generates very large matrices and it seems to save all results, so it requires large amount of RAM to load and storage to save it.  

There used to be a pop-up prompt not to save the results of the worksheet - to save space, but that no longer occurs.  Can someone help me to switch on that prompt not to save results or otherwise prevent saving results, when I open the spreadsheet.  It maybe that I agreed not to be prompted again, but now I am regretting it!!


I have a system of equations e.g.


where A,B,C are Matrices and I want to solve for A.

Sure I can write every equations in brakets [..=0], but isn'T it possible to just use the matrix notation?


This Application uses the xrite color checker to obtain Forward and Color Matrices as defined by Adobe.

It compares the camera gamut based on the above matrices to the 1931 Standard Observer using LEDs.




assume a,b,c,d,B2,B3 are matrices and y is unknown

eq2 := a*b+c*d+a;
eq3 := a*c+c*d+c;
eq4 := a*b+c*a+b*c;
eq5 := a*b+a*d+b*c;

which function can solve this kind of system of matrices?

how to solve a,b,c,d in terms of y?

a1 := Matrix(3, [1, 2, 3, 7, 8, 9, 13, 14, 15]);
a2 := Matrix(3, 2, [5, 6, 11, 12, 17, 18]);
a3 := Matrix(2, [19, 20, 25, 26]);
a2 := Matrix(3, 2, [5, 6, 11, 12, 17, 18]);

i want to combine above matrices in big matrix like

A := Matrix(2, 2, [a1, a2, a3, a4]);

best regards


Here is my code

P := unapply(Matrix(4, 4, {(1, 1) = p[w], (1, 2) = p[x], (1, 3) = p[y], (1, 4) = p[z], (2, 1) = -p[x], (2, 2) = p[w], (2, 3) = -p[z], (2, 4) = p[y], (3, 1) = -p[y], (3, 2) = p[z], (3, 3) = p[w], (3, 4) = -p[x], (4, 1) = -p[z], (4, 2) = -p[y], (4, 3) = p[x], (4, 4) = p[w]}),(p[w],p[x],p[y],p[z]));

(y1, y2, y3, y4) -> rtable(1 .. 4, 1 .. 4, {(1, 1) = y1,

(1, 2) = y2, (1, 3) = y3, (1, 4) = y4, (2, 1) = -y2,

(2, 2) = y1, (2, 3) = -y4, (2, 4) = y3, (3, 1) = -y3,

(3, 2) = y4, (3, 3) = y1, (3, 4) = -y2, (4, 1) = -y4,

(4, 2) = -y3, (4, 3) = y2, (4, 4) = y1}, datatype = anything,

subtype = Matrix, storage = rectangular, order = Fortran_order)


for j from 1 to 3 do;
for k from 1 to 5 do;
S[j,k]:=P(seq(RandomTools[Generate](integer(range = 0 .. 4)),i=1..4));;
end do:
end do:
for j from 1 to 3 do;
for k from 1 to 5 do;
end do:
end do:

for j from 1 to 3 do;
for k from 1 to j do;
end do:
end do:
for j from 1 to 3 do;
for k from j+1 to 3 do;
end do:
end do:

I would like the output to be a 4x4 matrix.

Dears, When I run calculation in Maple I found an error in matrices. See the file



I am trying to construct a series of 10X10 matrices whose main diagonal contains exactly k ones and other entries zero.


plz suggest thanks

Hi all,

I am considering a scenario in which I have, for example, four matrices, A, B, C, and D, which form a basis for all of the (numerical) calculations I am doing.  (For example, A + B = i*C, etc.)  Right now, if I add A and B, I get a matrix back whose elements are i*C, but I cannot get Maple to express it as i*C.  As a simple example, let:

A = (1 0 // 0 1 )

B = (0 1 // -1 0)

C = (i i // -i i)

Then A + B returns (1 1 // -1 1); I'd like for Maple to "intelligently" give iC. can I get Maple to expand a given matrix (A+B) in terms of a particular basis (here, simply C)?

Thank you.


Consider the following code, which just generates two "identical" matrices, differing only in their requested storage type, and then does some simple manipulations.

# Define matrix using sparse storage
   testM:= Matrix( 40,40,
# Define identical(?) matrix with rectangular storage
   nm:= Matrix( 40,40,
# Define procedure to return some matrix properties
   matData:= proc( myMat::Matrix)
                            return op(3, myMat)[2], # check storage type
                                      myMat[5, 1..-1], # get 5-th row
                                      add(myMat[5, 1..-1]); # add elements in 5-th row
                    end proc:
# Get properies of the two matrices - should be identical
# but check result of adding elements in the 5-th row

The matData procedure ought to produce the same results for the two matrices, with the exception of the storrage type. But the 'add()' command does not. The 'myMat[5, 1..-1]' command produces the same vector, the 5-th row - but stick an add() wrapper around it and all hell breaks loose.

Is this a bug or am I missing something?

Suggestions such as avoiding sparse data storage are not really acceptable: the above is a much simplified version of my original problem where I was using graph theory to play with a "cost function" and (with G a graph) the command,


returned a sparse-storage matrix - and I didn't notice. There appears to be no option on the WeightMatrix() command to control the storage tyoe of the returned matrix. Result was that all subsequent code based on slicing/dicing/and particularly 'add()ing' sub-blocks of this weight matrix fell apart

Don't get me wrong: I can sort of accept that the weight matrix of minimal spanning tree would (hopefully) be mainly zeros so sparse-storage might be a good default option but I don't see why the results of a command such as

add(myMat[5, 1..-1])

should vary depending on the internal storage used for the matrix, particularly when I have no control over the storage type being adopted


1 2 3 4 5 Page 1 of 5