Items tagged with matrix


In the Maple help to use a matrix defined monomial order it is said to define a matrix and a list of variables and then typing 'matrix'(M,V). But I fail to use it. A very simple example:

Groebner[LeadingMonomial](y^3+x*y, 'matrix'(M, V));

But Maple shows this error:


Error, invalid input: Groebner:-LeadingMonomial expects its 2nd argument, tord, to be of type {MonomialOrder, ShortMonomialOrder}, but received matrix(Matrix(2, 2, {(1, 1) = 1, (1, 2) = 0, (2, 1) = 0, (2, 2) = 1}), [x, y])

What is wrong?

I am writing a matrix to file where each matrix element is placed on a new line. An example of such code:


nRow,nCol :=LinearAlgebra[Dimension](HH);
for i from 1 to nRow do
   for j from 1 to nCol do

When this is printed to file, it will print as the power sign ^ regardless of the input it is given. This particular output file will be read in by another language, and due to this the power symbol "^" is not desired, but instead " ** ". By converting the matrix into a string format and applying string operations, this can be done; but is there a simpler way to do it?



I am solving a simple system of algebraic equations in a "for" loop. I would like to write all the values of solutions to a matrix, but I only get the symbols. Here is my code:

for i from 1 to m do
 rozw||i:=fsolve({r1||i, r2||i}, {H||i,V_A||i},H||i=0..1);Force(i,1):=H||i;Force(i,2):=V_A||i;subs(rozw||i,Force(i,..));
end do:

Thanks in advance,



I'm having trouble seeing which command is calling the "thaw" for the code below and was wondering if someone is able to save me the trouble from working it out myself. i know its not when the "is" function is called from viewing the showstat for it, but the output prior to mapping that function pops out with no troubles, so im guessing its the generic mapping proc, but of course, in built function so i can only assume its the same way i would write it but im pretty sure i dont use thaw either so anyway the line in question:

map(is, seq(seq(map(eval, Matrix(3, omega[1]) = Matrix(3, omega[0]), [n = i, m = j]), i = 1 .. 10), j = 1 .. 10));
Error, (in thaw) too many levels of recursion


Dear all

I have a linear system and I would like to generate the matrix from the linear system of equations

Many thanks for your help


dear all,

I have a problem when I try to find points on boundary of the surface.

the surface ploted from a matrix as follow:


please help me to generate a bondary curve of this surface.






I am using codegen to generate code from Maple expressions. More specifically I want to export non quadratic matix. The export works for matrices that have more columns than rows, but not for matrices with more rows than columns. There I receive the error:

Error, (in codegen/array/entry) 2nd index, 3, larger than upper array bound 2

A workaround would be to transpose the matrix before the export, and to transpose on the import (in Matlab) but I don't want to overcomplicate my code. Thanks for your help!

I have attached a demonstration worksheet below.


## test codegen non quadratic returnarray

## works
#Myfun := Matrix(3,3)

## works
#Myfun := Matrix(2,3):Myfun(2,3):= 3*b;

## does not work
Myfun := Matrix(3,2):Myfun(3,2):= 3*b;

Myfun := Matrix(3, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0, (3, 1) = 0, (3, 2) = 3*b})


Myfun(1):= 7*a;

Myfun := Matrix(3, 2, {(1, 1) = 7*a, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0, (3, 1) = 0, (3, 2) = 3*b})


## codegen works best with arraybased matrices, and call by reference becomes possible

returnArray:= convert(Myfun,matrix)

returnArray := Matrix(3, 2, {(1, 1) = 7*a, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0, (3, 1) = 0, (3, 2) = 3*b})



Error, (in codegen/array/entry) 2nd index, 3, larger than upper array bound 2



Error, (in codegen/array/entry) 2nd index, 3, larger than upper array bound 2



Error, (in codegen/array/entry) 2nd index, 3, larger than upper array bound 2






How to write a code find fundamental matrix of the following Matrix?

restart; with(LinearAlgebra): A:=Matrix([[0, 1, 0, 0], [-a, 0, b, 0], [0, 0, 0, 1], [c, 0, -d, 0]]);eigenvectors(A);

where a,b,c,d∈IR.

I want to find eigenvalues and eigenvectors and then want to calculate e^( λ i)*ri  where λi's are eigenvalues, ri's are eigenvectors of A for i=1,2,3,4  respectively.

Then, I want to calculate Wronskian of the matrix which consists of vectors e^(λi)*ri in the columns. Could you help me?

See: Fundamental Matrix


i have a vector-valued function mapping from R^n  -> R^m
I  compute its Jacobian Matrix as well as the Hessian Matrix of each output with regard to the inputs, which works so far.
Now I would like to use the CodeGeneration package to generate optimized C Code to compute these matrices numerically. This is, where i encounter a Problem:

I would like to optimize Code for all matrixes at once, because they contain common subexpressions. However CodeGeneration::C tells me it is unable to optimize the given input and generates unoptimized code.

I appended an exemplary file to illustrate the problem:

short version:

C(Jac, optimize = tryhard, resultname = JacobianMatrix);
C(H1, optimize = tryhard, resultname = Hessian1); 
C(H2, optimize = tryhard, resultname = Hessian2); 
C(H3, optimize = tryhard, resultname = Hessian3)

works, but is suboptimal.

C([JacobianMatrix = Jac, Hessian1 = H1, Hessian2 = H2, Hessian3 = H3], optimize)

fails to optimize and

C([Jac, H1, H2, H3], optimize)

fails completely.

(With Jac beeing a m by n matrix and H1-3 beeing n by n matrices)

If anyone can tell me what I'm missing here I'd really appreciate the help.

I know that is easy for you but i am new in this topics.I want to write a code to generate a matrix which have entries consist of matrices(it has differnt dimensions)

I need to create a list of matrices.

for b from 1 to 12 by 5 do
if i=b+P[a] and j=b+P[a] then E[a]
elif i=b+P[a] and j=b+N+2+P[a] then -E[a]
elif i=b+P[a]+N+2 and j=b+P[a] then -E[a]
elif i=b+P[a]+N+2 and j=b+P[a]+N+2 then E[a]
else 0:
end if:
B[b]:=add(i,i=[seq(Matrix(20,B), a=1..3)]);
end do;

It isn't indexing the first and second variable, only the last one was indexed. 

I wrote some procedures in an older version of Maple to sort through a matrix and find repeated elements, and then set the matrix elements equal to one another. As an example, consider the matrix:

Matrix(4, 4, {(1, 1) = 31774769/38880000, (1, 2) = -90858559/233280000, (1, 3) = -76547233/69984000, (1, 4) = -119275567/139968000, (2, 1) = -90858559/233280000, (2, 2) = 1506841/6480000, (2, 3) = 442249/720000, (2, 4) = 85514221/116640000, (3, 1) = -76547233/69984000, (3, 2) = 442249/720000, (3, 3) = 592249771/349920000, (3, 4) = 121562339/87480000, (4, 1) = -119275567/139968000, (4, 2) = 85514221/116640000, (4, 3) = 121562339/87480000, (4, 4) = 170546323/87480000}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
Due to its symmetric nature the upper triangular matrix is just the same as the lower triangular. i.e. the elements are equal: (2,1)=(1,2), (3,1)=(1,3) etc...

I have attached a minimal working example Maple script, which processes an input matrix, finds repeats and sets the elements equal to one another (e.g. [1,2]=[2,1], literally printing this) and saves the output to a file using a specific format for processing by another program. The matrix in the file is numeric but the actual matrices contain a lot of algebraic terms and can get quite large. This is where my procedures struggle as they take a very, very long time to process larger algebraic matrices to group the repeats. Is there a more Maple friendly way of going about this problem rather than these "archaic" procedures?

Here is the script:

Thank you in advance


How do I assume variables as  Matrixs for calculation?
Please help me to solve this problem :


A := M12*M21+M11;
                         M12 M21 + M11
solve(A = 0, M12);
Warning, solve may be ignoring assumptions on the input variables.
                             - ---
solve(A = 0, M12, useassumptions = true);
                             - ---

How can I get solution being a matrix?
Thank you very much !!!

I have a Maple code which generates a matrix, saves it to a .txt file and this is then read in to a C++ program. I have hit a snag with these matrices, in that they are generating absolutely enourmous .txt files. I need to get to a 5000*5000 matrix yet a 200*200 is generating a 100MB file.

The matrix elements contain a lot of algebraic terms which I would like to keep general as these are defined in the C++ code. They also contain hypergeometric functions which in the example below I have left unsimplified (although they are simplified before reaching C++). I have tried various operations/combinations to simplify, but the file sizes still come out very large.

From previous experience expanding the expressions and then simplifying allows Maple to "do more" with it, but it does not seem to work in this instance. I have tried map(options,expr), simplify(expr,options), combine(expr,options), convert (expr,options) etc... The script attached only contains a small example 10*10 matrix on its own without the code which generates it due to the size of the code. What is the best way to simplify these matrices to generate the smallest .txt file?

Any help is appreciated.



I have a question and I hope someone will be able to answer it.

I would like to create a matrix of functions depending on the number of the line or the arrow. I think the best is to show with a very basic example:

I have the following program



for i from 1 to n do: R(1,i):=x->i*x:end do:

So, I have a matrix, one row, n columns. At the ith column, I want to have the function f(x)=i*x.

Unfortutanely, with my program, I obtain for example for the first column the function f(x)=11*x. At the second column, I get the same result. It seems that I can define matrices of functions but it is impossible in the definition of the function to use the number of the column. Do you have any idea about how to write a program?

Any help would be very appreciated. 



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