## How to resolve a matrix of matrices?...

I want to create a matrix (B) from entries of other matrices (A) with a helper-function (helper). The helper function is defined such that it returns a certain matrix depending on the index variables. This is necessary because the inner matrices are constructed with another function.

Since the helper-function returns matrices, the big matrix is of datatype=matrix. Unfortunately, creating the big matrix with the correct size and forcing the datatype=float, does not yield the desired result. However, the manual definition using the constructor with a list of matrices does create the desired matrix.

How do I resolve a matrix of matrices?

Note: I know that I could write a convert function that copies the entries to a corresponding matrix, though this seems to be unnecessary effort to me.

This might not be minimal but shows the issue. (Compare and )

MWE_matrix_of_matrices.mw

 > restart; with(LinearAlgebra):
 > size_A := 2; size_B := 3;
 (1)
 > helper2 := proc(i::integer,j::integer);   if i=j then     a;   elif i=j-1 or i=j+1 then     b;   else     c;   end if; end proc: helper3 := proc(i::integer,j::integer);   if i=j then     Matrix(size_A,size_A,helper2);   elif i=j-1 or i=j+1 then     -IdentityMatrix(size_A);   else     Matrix(size_A);   end if; end proc: A := Matrix(size_A, size_A, helper2); B := Matrix(size_B, size_B, helper3); B := Matrix(size_B,size_B, helper3, datatype = float); B := Matrix(size_B*size_A, size_B*size_A,[Matrix(size_B,size_B,helper3)], datatype = float)
 > test := Matrix(4, 4, [                 [Matrix([[1,2],[0,9]]), Matrix([[3,6],[0,9]])],                 [Matrix([[3,4],[7,8]]), Matrix([[7,6],[5,5]])]                ]); # is converted to a matrix of floats
 (2)

## Levi-Civita symbol and inverse of matrix...

Hi

We know determinant of a square matrix A[ij] (i,j ∈ {1,2,3}) is equal to the following expression

det(A) = 1/6 * e[ijk] * e[pqr] * A[ip] * A[jq] * A[kr]

in which e[ijk] is a third order Tensor (Permutation notation or Levi-Civita symbol) and has a simple form as follows:

e[mnr] = 1/2 * (m-n) * (n-r) * (r-m).

The (i,j) minor of A, denoted Mij, is the determinant of the (n − 1)×(n − 1) matrix that results from deleting row i and column j of A. The cofactor matrix of A is the n×n matrix C whose (i, j) entry is the (i, j) cofactor of A,

C[ij]= -1 i+j * M[ij]

A-1=CT/det(A)

The general form of Levi-Civita symbol is as bellow:

I want to write a program for finding inverse of (NxN) matrix:

N=2 →

restart;
N := 2:
with(LinearAlgebra):
f := (1/2)*(sum(sum(sum(sum((m-n)*(p-q)*A[m, p]*A[n, q], q = 1 .. 2), p = 1 .. 2), n = 1 .. 2), m = 1 .. 2)):
A := Matrix(N, N, proc (i, j) options operator, arrow; evalf((37*i^2+j^3)/(2*i+4*j)) end proc):
f/Determinant(A);

N=3 →

restart;
N := 3:
with(LinearAlgebra):
f := (1/24)*(sum(sum(sum(sum(sum(sum((m-n)*(n-r)*(r-m)*(p-q)*(q-z)*(z-p)*A[m, p]*A[n, q]*A[r, z], m = 1 .. N), n = 1 .. N), r = 1 .. N), p = 1 .. N), q = 1 .. N), z = 1 .. N)):
A := Matrix(N, N, proc (i, j) options operator, arrow; 10*i^2/(20*i+j) end proc):
f/Determinant(A);

The results of above programs are equal to 1 and validation of method is observed.

If we can write the general form of determinant then we can find the inverse of any square non-singular matrices.

Now I try to write the mentioned program.

restart;
with(linalg):
N := 7:
Digits := 40:
e := product(product(signum(a[j]-a[i]), j = i+1 .. N), i = 1 .. N):
ML := product(A[a[k], b[k]], k = 1 .. N):
s[0] := e*subs(`\$`(a[q] = b[q], q = 1 .. N), e)*ML:
for i to N do
s[i] := sum(sum(s[i-1], a[i] = 1 .. N), b[i] = 1 .. N)
end do:
A := Matrix(N, N, proc (i, j) options operator, arrow; evalf((3*i+j)/(i+2*j)) end proc): # arbitrary matrix
CN:=simplify(s[N]/det(A));

Therefore det(A)= CN-1 * e[a1,a2,..an] * e [b1,b2,.., bn] * A[a1,b1] * A[a2,b2] * ... * A[an,bn].

The correction coefficient is CN(for N)/CN(for N-1) = N!/(N-1)! =N.

restart:
with(linalg): N := 4: Digits := 20:
e := product(product(signum(a[j]-a[i]), j = i+1 .. N), i = 1 .. N):
ML := product(A[a[k], b[k]], k = 1 .. N):
s[0] := e*subs(`\$`(a[q] = b[q], q = 1 .. N), e)*ML:
for r to N do s[r] := sum(sum(s[r-1], a[r] = 1 .. N), b[r] = 1 .. N) end do:
A := Matrix(N, N, proc (i, j) options operator, arrow; evalf((3*i+2*j)/(i+2*j)) end proc):
DET:=S[N]:
for x to N do for y to N do
e := product(product(signum(a[j]-a[i]), j = i+1 .. N-1), i = 1 .. N-1):
ML := product(AA[a[k], b[k]], k = 1 .. N-1):
S[0, x, y] := e*subs(`\$`(a[q] = b[q], q = 1 .. N-1), e)*ML:
for r to N-1 do S[r, x, y] := sum(sum(S[r-1, x, y], a[r] = 1 .. N-1), b[r] = 1 .. N-1) end do:
f[y, x] := (-1)^(x+y)*subs(seq(seq(AA[t, u] = delrows(delcols(A, y .. y), x .. x)[t, u], t = 1 .. N-1), u = 1 .. N-1), S[N-1, x, y])
end do: end do:
Matrix(N, N, f)/(DET)*(24/6);
A^(-1);

CN for N=4 and N=3 is 24 and 6 respectively i.e. CN(4)/CN(3)=24/6.

When I use bellow procedure the error "(in S) bad index into Matrix" is occurred.

Thank you

restart; with(linalg): Digits := 40: n := 7:
S := proc (N) local e, ML, s, i:
e := product(product(signum(a[j]-a[i]), j = i+1 .. N), i = 1 .. N):
ML := product(A[a[k], b[k]], k = 1 .. N):
s[0] := e*subs(`\$`(a[q] = b[q], q = 1 .. N), e)*ML:
for i to N do s[i] := sum(sum(s[i-1], a[i] = 1 .. N), b[i] = 1 .. N) end do
end proc:
A := Matrix(n, n, proc (i, j) options operator, arrow; evalf((3*i+j)/(i+2*j)) end proc): # arbitrary matrix
CN := simplify(S(n)/det(A))

## Matrix in TimeSeriesAnalysis...

How can I use a matrix in timeseriesanalysis?

m3 := Import("d:\\bok6.xlsx")

Areachart works fine:

AreaChart([m3], color = "pink" .. "niagara Navy", title = "Tidslinje Tilluft og avtrekk")

But when matrix m3 is entered in timeseriesanalysis it gives a error:

ts1 := TimeSeries([m3], startdate = "2016-08-1", header = "Tilluft VAV setpunkt", enddate = "2016-08-01");

Error, (in TimeSeriesAnalysis:-TimeSeries) invalid input: too many and/or wrong type of arguments passed to TimeSeries:-ModuleCopy; first unused argument is [Array(1..4, 1..1, {(1, 1) = 155.0, (2, 1) = 142.0, (3, 1) = 133.0, (4, 1) = 122.0})]

I have loaded the following packages:

with*matrix  with*linearalgebra  with(plots)  with(Statistics)  with(TimeSeriesAnalysis)

Regards

Kristian

## Can't assign values from a procedure...

I defined a procedure, OrderB(0,b,c), that essentially determines the order of a group that is defined by 2 parameters (the first parameter is always zero), so the output is an integer and the procedure is defined for every integer value of both parameters. I wanted to structure the outputs into a matrix with columns that represent one parameter and rows that represent the other. However, whenever I try to apply a method of defining the matrix, Maple returns the values of the procedure and then gives me an empty matrix.

>f:=proc (i, j) -> OrderB(0, i, j+3);
>Matrix(3, f);
1
4
1
1
4
1
1
4
1
[NULL,NULL...]

I tried a second method where I defined a set s such that:

s:={(0,0)=OrderB(0,0,0) , (0,1)=OrderB(0,0,1).....}

but upon execution, maple returns:

1
4
1
....
s:={(0,0)=( ), (0,1)=( )...}

Please Help. I don't know what I'm mising in the code that is keeping Maple from putting the outputs of my procedure into the matrix.

## Generate matrix form ...

Hello,

I cant find solution how to create matrix form from equations of motion. Equations looks like this:

My equations ar much more complicated and one of them looks something like this:

http://i63.tinypic.com/21c5ctk.png

and I want form like this:

I tried to do it using the Generate Matrix but it does not work as I expected. How can you get this form?

## How to re-evaluate a Matrix?...

How do I get the Matrix to recalculate?

 (1)

 (2)

 (3)

 (4)

 (5)

## Displaying Large Matricies and Vectors...

I am using a stoiciometric matrix to generate a system of differential equations (this makes them easier to check). There are 13 chemical species and 16 reactions so I need to make and display vectors of length 13 and 16; as well as a 13x16 matrix.

When I make Vectors of this size they don't get displayed; I just get information about the vector (Fortran order etc) and this is the same for the matrix.

How do i make/edit/display Matrixes nd Vectors of this size?

## Generate invertible 4x4 matrices over F_2 ...

Hi, here is the code I used to try to generate all invertible 4x4 matrices over the finite field F_2 = {0.1}. However, when I look at the elements of GROUP (see below) all the elements are 4x4 matrices with a 2 in each entry. I don't know why this is?

Also, I need help converting all of the invertible 4x4 matrices in the following way: I want the 4x4 matrices to each be written as a string of length 16 with no spaces, commas or brackets. So for example the matrix

a b c d

e f g h

i j k l

m n o p

becomes abcdefghijklmnop

restart:
with(LinearAlgebra):
PRIME := 2;
2

# the group of invertible 4 x 4 matrices over the field F_p

GROUP := []:
M := Matrix([[a,b,c,d],[x,f,g,h],[y,j,k,l],[m,n,o,p]]):
for a from 0 to PRIME-1 do
for b from 0 to PRIME-1 do
for c from 0 to PRIME-1 do
for d from 0 to PRIME-1 do
for x from 0 to PRIME-1 do
for f from 0 to PRIME-1 do
for g from 0 to PRIME-1 do
for h from 0 to PRIME-1 do
for y from 0 to PRIME-1 do
for j from 0 to PRIME-1 do
for k from 0 to PRIME-1 do
for l from 0 to PRIME-1 do
for m from 0 to PRIME-1 do
for n from 0 to PRIME-1 do
for o from 0 to PRIME-1 do
for p from 0 to PRIME-1 do
if Determinant(M) mod PRIME <> 0 then
GROUP := [ op(GROUP), M ]
fi
od od od od od od od od od od od od od od od od:

nops(GROUP);
20160

GROUP;

## How can I find explicit relations between columns ...

Hi everybody!

I am trying to find explicitely the relations between the columns of a matrix

of non-maximal rank. For example, if I have the matrix

M := Matrix([<1,2,3>, <2,4,6>, <5,6,7>]);

I would like that Maple finds that the second column is twice the first one: v_2 = 2*v_1.

How can I do?

## Problem with differential operator...

hi.please see attached file below and help me.one problem is apply differential operator on matrix and then caclute 3D integral?

maple2.mw

 (1)

 (2)

 (3)

 (4)

 (5)

 (6)

 (7)

 (8)

 (9)

## How I can write a matrix of square size 15? ...

Hello

I try to write a matrix (15*15) by maple, but the maple programme doesn't run this.

Here I attached the worksheet.

 >
 >
 (1)
 >
 >
 (2)
 > n:=14:
 > for v from 0 to n do
 > p[v,n]:=expand(binomial(n,v)*x^(v)*(1-x)^(n-v))
 > end do:

 (3)

 (4)

d1 := MatrixInverse[Q](d);

 (5)

 >
 >
 (1)
 >
 >
 (2)
 > n:=14:
 > for v from 0 to n do
 > p[v,n]:=expand(binomial(n,v)*x^(v)*(1-x)^(n-v))
 > end do:

 (3)

 (4)

d1 := MatrixInverse[Q](d);

 (5)

## Groebner produces inconsistent result...

Hello,

Calculated a Grobasis basis. Used the 19 of the 29 equations to produce a Sylvester type matrix to get a univarite polynomial. The problem I am having is I can't produce a consistant matrix. I think the problem may lie in how I sort the equations. I have used this method once before and it worked to produce the result then. Run the worksheet and the run it again and most likely a different outcome occurs. I copy and pasted the polynmial list to make this worksheet. The coefficients are very long. Have annotated the worksheet to help explain.

## Possible bug in Eingenvalues...

I am using maple 13 to found Eingenvalues of an hermitian matrix :

M1:=Matrix([
> [lambda3+lambda4,0,0,0,0,0,lambda4/sqrt(2),0,0,I*lambda4/sqrt(2)],
> [0,lambda3/4,0,0,0,0,0,0,0,0],
> [0,0,lambda3/4,0,0,0,0,0,0,0],
> [0,0,0,lambda3/4,0,0,0,0,0,0],
> [0,0,0,0,lambda3/4,0,0,0,0,0],
> [0,0,0,0,0,lambda3,0,0,0,0],
> [lambda4/sqrt(2),0,0,0,0,0,lambda3/2,0,0,0],
> [0,0,0,0,0,0,0,lambda2,0,0],
> [0,0,0,0,0,0,0,0,lambda2,0],
> [-I*lambda4/sqrt(2),0,0,0,0,0,0,0,0,lambda4/2]
> ]);

>Eigenvalues(M1);

my surprise is that maple gives me 8 correct solutions an 2 complex eigenvalues which are not acceptable (we now that the eigenvalues for an hermitian matrix are all real) .

To understand the output of maple, first,  I suspect that the complex part of the roots was null but without success I haven't found how to do it zero...

is it a bug? Thanks a lot to cooperation

## Matrix of linear system...

Hello..  I want to know if there is anny command to show the matrix of linear system.  I recently entred a 64 equations and i solved it by command solve,  but i want to show the matrix of system..  So plz. Help

## Why doesn't matrix create?...

hi .why matrix a dont create?

 (1)

 (2)

 (3)

 (4)