Items tagged with matrix matrix Tagged Items Feed

Hi,

I have this 5 by 2 matrix, and I want to form  lists of lengths 5, whereby the ith entry in my list should be any of the elements from the ith row of the matrix. How do i get all the possible lists? (I am expecting a total of 32lists, each of length 5):

Hello! 

In an assigment I have been asked to use the Eigenvectors command to find the eigenvalues and eigenvectors of a particular matrix. 

As highlighted in the following image, my questions are:

1. What is the meaning of the suffix "+0.I"? Does it mean that there are further decimal digits which are not displayed?

2. How do the first and third eigenvalues, which are equal, result in different eigenvectors? As per my understanding, equal eigenvalues should have equal corresponding eigenvectors. Please help.

I have a system of equations e.g.

A^2+B*A+C=0

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?

I've been trying to numerically solve (and plot) this equation. Maple tells me that some matrix is singular - I have no idea, what I can do.

eq := diff(y(x), `$`(x, 3))-(diff(y(x), x))*(diff(y(x), x))+1 = 0;

cond := (D(y))(0) = 0, (D(y))(1) = 1, ((D@@2)(y))(0) = 0

de := dsolve({cond, eq}, y(x), numeric);

Error, (in dsolve/numeric/bvp) matrix is singular

Hi,

 

I am trying to solve a simple system of the form AX=0, where A is a N*N matrix, X is an N*1 vector (and the right-hand side of the equation is an N*1 vector of zeros, I apologize for the inexact notation). The difficulty comes from the fact that the values of A are parameterized by 2*N parameters (that I will write as the 2*N vector P), and I would like to get a solution in the form X=f(P).

 

One solution is to try to use LinearAlgebra[LinearSolve], but it only returns the trivial solution X=0, which I am not interested in.

Another solution is to compute analytically the Moore-Penrose pseudoinverse Ag of A, as the general solution is of the form

(I - Ag A)f ;

where f is a vector of free parameters. However, even for a small matrix size (N=4), Maple is still computing after 3 hours on my (fairly powerful) machine, and it is taking more and more memory over time. As the results are polynomial/rational equations in the parameters P, I was actually expecting Maple to be more powerful than other softwares, but for this particular problem, Matlab's symbolic toolbox (muPAD) gives quick solutions until N=6. I need, in the end, to solve additional polynomial/rational equations that are derived from the solutions X=f(P), where Matlab fails. This is why I would really like to be able to solve the above-mentioned problem AX=0 with Maple in order to try to solve the subsequent step of the problem (polynomial system) with Maple.

 

Any suggestions on how to do this would be highly appreciated! Thank you very much for your time and help.

 

Laureline

When I print 2 matrix it always try to multiply them. How to force just to show?

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 B and test)

MWE_matrix_of_matrices.mw

restart;
with(LinearAlgebra):

size_A := 2;
size_B := 3;

2

 

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)

A := Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})

 

B := Matrix(3, 3, {(1, 1) = Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a}), (1, 2) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (1, 3) = Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0}), (2, 1) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (2, 2) = Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a}), (2, 3) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (3, 1) = Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0}), (3, 2) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (3, 3) = Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})})

 

Error, (in Matrix) unable to store 'Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})' when datatype=float[8]

 

Error, (in Matrix) unable to store 'Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})' when datatype=float[8]

 

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

test := Matrix(4, 4, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 3, (1, 4) = 6, (2, 1) = 0, (2, 2) = 9, (2, 3) = 0, (2, 4) = 9, (3, 1) = 3, (3, 2) = 4, (3, 3) = 7, (3, 4) = 6, (4, 1) = 7, (4, 2) = 8, (4, 3) = 5, (4, 4) = 5})

(2)


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.

Please help me to write this algorithm by using procedure.

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))

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

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.

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 do I get the Matrix to recalculate?

restart

a := 5

5

(1)

``

M := simplify(Matrix(2, 2, {(1, 1) = a, (1, 2) = 2*a, (2, 1) = 3*a, (2, 2) = a^2}))

M := Matrix(2, 2, {(1, 1) = 5, (1, 2) = 10, (2, 1) = 15, (2, 2) = 25})

(2)

``

unassign('a')

a

a

(3)

 

M

Matrix(2, 2, {(1, 1) = 5, (1, 2) = 10, (2, 1) = 15, (2, 2) = 25})

(4)

expand(M)

Matrix(2, 2, {(1, 1) = 5, (1, 2) = 10, (2, 1) = 15, (2, 2) = 25})

(5)

``

 

Download Re-evaluate_a_Matrix.mw

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?

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;


----------------------------------------------------------------------------------------------------------------------
Introduction

I have a matrix (named DC on the piece of code below) all the elements of which are complex numbers a+b*I with a and b floating point numbers.
I want to obtain the real part of DC.

Obviously, if you do something like :
DC := Matrix(2,2, [1.0+1.0*I, 1.0-1.0*I, -1.0+1.0*I, -1.0-1.0*I];
Re~(DC);

the result corresponds to the desired matrix

----------------------------------------------------------------------------------------------------------------------
Context

In fact this matrix DC comes from some computations  described in the piece of code below

# Purpose :
# Given N points in a plane (here  in [0,1]X[0,1]), compute the matrix DX of distances between these points
#
# Example : if Pi and Pj are two such points, DX[i,j]=DX[j,i] denotes the Euclidian distance between Pi and Pj
#
# As I did not be able to find any single function in MAPLE that would construct DX , I proceed that way :
#   1/ let X the (N,2) matrix that contains the coordinates of the N points
#   2/ I represent these  N points as N complex numbers (vector C)
#   3/ I construct the (N,N) matrix MC = <C | C …..| C>
#   4/ I put MC = C – Transpose(C) :
#   5/ I take the norm DX of each elements of DC : DX := abs~(DC)
#       At this point, DX should contain the desired distances
#       But, due to floating point arithmetics, each element of DX writes a+0.*I where a is some floating point number)
#   6/ Last stage : execute Re~(DX)
#

with(Statistics):
with(LinearAlgebra):

N := 4:
X := Matrix(N,2, convert(Sample(Uniform(0,1), 2*N), list)):  #just an example

C   := X[..,1] +~ X[..,2] *~I;
MC := Multiply(C, Vector[row](N, 1));
DC := MC - Transpose(MC);
DX := abs~(DC);
Re~(DX)


----------------------------------------------------------------------------------------------------------------------
 My observations : 

1/ Maple 2015, Windows XP, 64 bytes
Re~(DX) returns DX and does not remove the imaginary (0.*I) part
But  Matrix(N, N, Re~(convert(DC, list))) does (which is a satisfactory, even if not clever, stopgap)

Why (it is just a question to help me to understand correctly how MAPLE proceeds) Re~(DC) does not (seem) to work here ?


2/ Maple 2015.2, Mac OS X El Capitan
DX := abs~(DC) gives me this strange result :
If (for instance) DC[i, j] = -1 – 2*I, DX[i, j] = +1 + 2*I
According to the compatibility problems between Maple 2015.1 and “El Capitan” (fixed from February), could it remain a few other problems ?

Last but not lesat : Did I do any syntax error ?


 I look forward to your responses

1 2 3 4 5 6 7 Last Page 1 of 42