Items tagged with linear-algebra


Generate 8 random 3 by 3 matrices using the RandomMatrix command from the  LinearAlgebra package. As each matrix is generated use Eigenvalues to compute its eigenvalues. Then take the product of the eigenvalues, and check that for each matrix, this product is equal to the determinant of the matrix.  
 

Since GramSchmidt does not take Matrix as an input (I wish it did), I would like to know how to normalize a matrix rows. For example if input matrix is:

M = [  1    2]
       [  3    4]

How do I convert it into

Mn = [ 1/sqrt(5)    2/sqrt(5) ]
         [ 3/5            4/5          ]

Each row of matrix Mn has length of 1.

Thank you.

 

So i got this code, im trying to iterate with jacobi and gaussseidel method.

H := HilbertMatrix(n, n, 1); b := Matrix(n, 1, proc (i) options operator, arrow; add(1/(i+j-1), j = 1 .. n) end proc); A := Matrix(n, 1, 1); Multiply(H, A); norm1H := norm(H, 1); norm2H := norm(H, 2); normHinf := norm(H, infinity); norm1b := norm(b, 1); norm2b := norm(b, 2); norminfb := norm(b, infinity); IterativeApproximate(H, initialapprox = Vector(n, 0), tolerance = 10^(-7), maxiterations = 10, method = gaussseidel)

 

But sadly no iteration gave me an answer, anyone knows wheres my mistake? i really help with this! 


thanks in advance

[Delta][4*4]*{b}[4*1]={0}

Which {b} is an eigenvector

Let say I have a linear system of equations with 28 unknowns (Z1, Z2, ..., Z28).

I know that dimension of space of solution > 0. I want for all unknowns to be expressed only by (let say: Z20, Z21, ..., Z28).

How to specify these free variables? I'm pretty sure it is implemented in Maple.

I'm trying to compute the tensor product of two column vectors as

 

with(LinearAlgebra):

A:=Matrix([[1/sqrt(2)],[0],[0],[1/sqrt(2)]]);

KroneckerProduct(A,A);

 

And the output is a column vector with entries: "16 x 1 Matrix", "Data Type: Anything", "Storage: rectangular", "Order: Fortran_order"

 

The Maple documentation indicates that this function should output the result of the kronecker tensor product of the input matrices, and I've followed the same form as the examples in the documentation... Does anyone know why this isn't working as it should?

 

 

 

I have tried to solve a matrix with the function "LinearSolve" as seen in the picture, but instead of solving it just gives me back the operation i wrote (3). My which is to solve an equation system a quick as possible - have a templet fill in the matrix and press enter. I thought this "LinearSolve" function was the easiest way of doing. I know that I can right click and choose the function, but I want it as a command.

 

Any solutions on how to use the "LinearSolve" command to solve an equation system?

 

for example is there an existing package for reducing groups of matrices like the one below to only its unique elements, or do i basically need to use  linear algebra matrix operations ie finding the basis of the set via echeleon reduction blah blah

 

{Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = -673/2880}), Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = -5/96}), Matrix(2, 2, {(1, 1) = 0, (1, 2) = -(2521/17920)*Zeta(5), (2, 1) = 0, (2, 2) = -(2521/17920)*Zeta(3)-2087/1920}), Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0}), Matrix(2, 2, {(1, 1) = 0, (1, 2) = -(7/320)*Zeta(5), (2, 1) = 0, (2, 2) = -(7/320)*Zeta(3)-499/840})}

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.

Hi, I want to ask. the maple program that i have done have something wrong somewhere.

for an example changes basis

 from e_{1}e_{1}=e_{1} , e_{1}e_{2}=e_{2} maple program reading :A1 : (1,1,1)=1,B1: (1,2,2)=1

to e_{2}e_{2}=e_{2} , e_{2}e_{1}=e_{1} maple program reading :A2: (2,2,2)=1,B2: (2,1,1)=1

these changes basis above are 2 operation, left product and right product

A1 and A2 are left product, while B1 and B2 are right product,

i need to make A1 isomorphic to A2, and B1 isomorphic to B2.

by using maple program, i should get identity in matrix form 2x2

[0 1] but i get [0         1]

[1 0],            [C_{21} 0],

For isomorphism, the determinant should not be zero

here's are my maple program:

>isom := proc (A1, A2, B1, B2, n)

local i, j, k, s, r, eqns, t, TEST, BChange, sols, m, S1, S2, C;

C := matrix(n, n);

BChange := matrix(n, n);

TEST := 0; eqns := {};

for i to n do for j to n do for m to n do

S1 := sum(A1[i, j, k]*C[k, m], k = 1 .. n); S2 := sum(C[i, r]*(sum(A2[r, s, m]*C[j, s], s = 1 .. n)), r = 1 .. n);

eqns := `union`(eqns, {S1 = S2})

end do end do end do;

for i to n do for j to n do for m to n do

S1 := sum(B1[i, j, k]*C[k, m], k = 1 .. n); S2 := sum(C[i, r]*(sum(C[j, s]*B2[r, s, m], s = 1 .. n)), r = 1 .. n);

eqns := `union`(eqns, {S1 = S2})

end do end do end do;

sols := [solve(eqns)];

t := nops(sols);

for i to t do for j to n do for k to n do

BChange[k, j] := subs(sols[i], C[k, j])

end do end do;

if simplify(linalg:-det(BChange)) <> 0 then print("BChange", BChange);

print("s1", S1); print("s2", S2); print("The det is", simplify(linalg:-det(BChange)));

TEST := 1 end if end do;

if TEST = 0 then print("These two algebras are not isomorphic")

end if end proc

input maple program:

> DENDA1 := array(sparse, 1 .. 2, 1 .. 2, 1 .. 2, [(1, 1, 1) = 1]);
> DENDB1 := array(sparse, 1 .. 2, 1 .. 2, 1 .. 2, [(1, 2, 2) = 1]);
> DENDA2 := array(sparse, 1 .. 2, 1 .. 2, 1 .. 2, [(2, 2, 2) = 1]);
> DENDB2 := array(sparse, 1 .. 2, 1 .. 2, 1 .. 2, [(2, 1, 1) = 1]);
> isom(DENDA1, DENDA2, DENDB1, DENDB2, 2);

Hello dear!

Hope everyone fine, I am facing to solve the attached problem please find and fix it. I am waiting your kind response. 

naveed.mw

hi.how i can determind  eignvalue of matrix in the form parametric?

thanks1.mw

T := Matrix(5, 5, {(1, 1) = -b*beta*k/(c*u)-d, (1, 2) = 0, (1, 3) = -beta*lambda*c*u/(b*beta*k+c*d*u), (1, 4) = 0, (1, 5) = 0, (2, 1) = b*beta*k/(c*u), (2, 2) = -s*(lambda*c*k*beta/(b*beta*k+c*d*u)-a)/P-a, (2, 3) = beta*lambda*c*u/(b*beta*k+c*d*u), (2, 4) = -s*b/c, (2, 5) = r*(s-p)/s, (3, 1) = 0, (3, 2) = k, (3, 3) = -u, (3, 4) = 0, (3, 5) = 0, (4, 1) = 0, (4, 2) = -s*(lambda*c*k*beta/(b*beta*k+c*d*u)-a)/P, (4, 3) = 0, (4, 4) = -s*b/c-b, (4, 5) = r*(s+c)/s, (5, 1) = 0, (5, 2) = s*(lambda*c*k*beta/(b*beta*k+c*d*u)-a)/P, (5, 3) = 0, (5, 4) = s*b/c, (5, 5) = -r})

Matrix(5, 5, {(1, 1) = -b*beta*k/(c*u)-d, (1, 2) = 0, (1, 3) = -beta*lambda*c*u/(b*beta*k+c*d*u), (1, 4) = 0, (1, 5) = 0, (2, 1) = b*beta*k/(c*u), (2, 2) = -s*(lambda*c*k*beta/(b*beta*k+c*d*u)-a)/P-a, (2, 3) = beta*lambda*c*u/(b*beta*k+c*d*u), (2, 4) = -s*b/c, (2, 5) = r*(s-p)/s, (3, 1) = 0, (3, 2) = k, (3, 3) = -u, (3, 4) = 0, (3, 5) = 0, (4, 1) = 0, (4, 2) = -s*(lambda*c*k*beta/(b*beta*k+c*d*u)-a)/P, (4, 3) = 0, (4, 4) = -s*b/c-b, (4, 5) = r*(s+c)/s, (5, 1) = 0, (5, 2) = s*(lambda*c*k*beta/(b*beta*k+c*d*u)-a)/P, (5, 3) = 0, (5, 4) = s*b/c, (5, 5) = -r})

(1)

``

 

Download 1.mw

 

Hello,

I have to calculate the eigenspace of a bunch of matrices and then intersect all together. Is it possible to have a procedure for this problem that returns a basis for the intersection of all the eigenspaces?

My matrices are tensor products of matrices so I was wondering whether there is a procedure to calculate the kronecker product of more than 2 matrices.

 

Thanks!

I thought I would share some code for computing sparse matrix products in Maple.  For floating point matrices this is done quickly, but for algebraic datatypes there is a performance problem with the builtin routines, as noted in http://www.mapleprimes.com/questions/205739-How-Do-I-Improve-The-Performance-Of

Download spm.txt

The code is fairly straightforward in that it uses op(1,A) to extract the dimensions and op(2,A) to extract the non-zero elements of a Matrix or Vector, and then loops over those elements.  I included a sparse map function for cases where you want to map a function (like expand) over non-zero elements only.

# sparse matrix vector product
spmv := proc(A::Matrix,V::Vector)
local m,n,Ae,Ve,Vi,R,e;
n, m := op(1,A);
if op(1,V) <> m then error "incompatible dimensions"; end if;
Ae := op(2,A);
Ve := op(2,V);
Vi := map2(op,1,Ve);
R := Vector(n, storage=sparse);
for e in Ae do
n, m := op(1,e);
if member(m, Vi) then R[n] := R[n] + A[n,m]*V[m]; end if;
end do;
return R;
end proc:
# sparse matrix product
spmm := proc(A::Matrix, B::Matrix)
local m,n,Ae,Be,Bi,R,l,e,i;
n, m := op(1,A);
i, l := op(1,B);
if i <> m then error "incompatible dimensions"; end if;
Ae := op(2,A);
Be := op(2,B);
R := Matrix(n,l,storage=sparse);
for i from 1 to l do
Bi, Be := selectremove(type, Be, (anything,i)=anything);
Bi := map2(op,[1,1],Bi);
for e in Ae do
n, m := op(1,e);
if member(m, Bi) then R[n,i] := R[n,i] + A[n,m]*B[m,i]; end if;
end do;
end do;
return R;
end proc:
# sparse map
smap := proc(f, A::{Matrix,Vector})
local B, Ae, e;
if A::Vector then
B := Vector(op(1,A),storage=sparse):
else
B := Matrix(op(1,A),storage=sparse):
end if;
Ae := op(2,A);
for e in Ae do
B[op(1,e)] := f(op(2,e),args[3..nargs]);
end do;
return B;
end proc:


As for how it performs, here is a demo inspired by the original post.

n := 674;
k := 6;
A := Matrix(n,n,storage=sparse):
for i to n do
  for j to k do
    A[i,irem(rand(),n)+1] := randpoly(x):
  end do:
end do:
V := Vector(n):
for i to k do
  V[irem(rand(),n)+1] := randpoly(x):
end do:
C := CodeTools:-Usage( spmv(A,V) ):  # 7ms, 25x faster
CodeTools:-Usage( A.V ):  # 174 ms
B := Matrix(n,n,storage=sparse):
for i to n do
  for j to k do
    B[i,irem(rand(),n)+1] := randpoly(x):
  end do:
end do:
C := CodeTools:-Usage( spmm(A,B) ):  # 2.74 sec, 50x faster
CodeTools:-Usage( A.B ):  # 2.44 min
# expand and collect like terms
C := CodeTools:-Usage( smap(expand, C) ):

Hi. I'm hacing trouble writing a maple procedure for the question below, can anyone help?

 

Write a maple procedure which takes as its input the vectoeat u1 and u2 and the eigenvectors lambda1 and lambda2 where u1,u2 are element of R^2 and the lambdas are real numbers.

If u1,U2 is linearly independent then the output is the matrix A an element of R^2x2 with the property that Au1= lambda1u1 and AU2=lambda2u2;

if u1,u2 is linearly dependent then the output is the statement "not an eigenbasis".

 

I I then have two inputs which I have to do but I'm not sure on how to write the procedure. Any help will be much appreciated.  

 

Thanks :)

 

 

1 2 3 4 5 Page 1 of 5