Items tagged with linear_algebra

Greetings to all. I am writing today to share a personal story / exploration using Maple of an algorithm from the history of combinatorics. The problem here is to count the number of strings over a certain alphabet which consist of some number of letters and avoid a set of patterns (these patterns are strings as opposed to regular expressions.) This counting operation is carried out using rational generating functions that encode the number of admissible strings of length n in the coefficients of their series expansions. The modern approach to this problem uses the Goulden-Jackson method which is discussed, including a landmark Maple implementation from a paper by D. Zeilberger and J. Noonan, at the following link at (Goulden-Jackson has its own website, all the remaining software described in the following discussion is available at the MSE link.) The motivation for this work was a question at the MSE link about the number of strings over a two-letter alphabet that avoid the pattern ABBA.

As far as I know before Goulden-Jackson was invented there was the DFA-Method (Deterministic Finite Automaton also known as FSM, Finite State Machine.) My goal in this contribution was to study and implement this algorithm in order to gain insight about its features and how it influenced its powerful successor. It goes as follows for the case of a single pattern string: compute a DFA whose states represent the longest prefix of the pattern seen at the current position in the string as it is being scanned by the DFA, with the state for the complete pattern doubling as a final absorbing state, since the pattern has been seen. Translate the transitions of the DFA into a system of equations in the generating functions representing strings ending with a given maximal prefix of the pattern, very much like Markov chains. Finally solve the system of equations for the generating functions and thus obtain the sequence of values of strings of length n over the given alphabet that avoid the given pattern.

I have also implemented the DFA method for sets of patterns as opposed to just one pattern. The algorithm is the same except that the DFA does not consist of a chain with backlinks as in the case of a single pattern but a tree of prefixes with backlinks to nodes higher up in the tree. The nodes in the tree represent all prefixes that need to be tracked where obviously a common prefix between two or more patterns is shared i.e. only represented once. The DFA transitions emanating from nodes that are leaves represent absorbing states indicating that one of the patterns has been seen. We run this algorithm once it has been verified that the set of patterns does not contain pairs of patterns where one pattern is contained in another, which causes the longer pattern to be eliminated at the start. (Obviously if the shorter pattern is forbidden the so is the longer.) The number of states of the DFA here is bounded above by the sum of the lengths of the patterns with subpatterns eliminated. The uniqueness property of shared common prefixes holds for subtrees of the main tree i.e. recursively. (The DFA method also copes easily with patterns that have to occur in a certain order.)

I believe the Maple code that I provide here showcases many useful tricks and techniques and can help the reader advance in their Maple studies, which is why I am alerting you to the web link at MSE. I have deliberately aimed to keep it compatible with older versions of Maple as many of these are still in use in various places. The algorithm really showcases the power of Maple in combinatorics computing and exploits many different aspects of the software from the solution of systems of equations in rational generating functions to the implementation of data structures from computer science like trees. Did you know that Maple permits nested procedures as known to those who have met Lisp and Scheme during their studies? The program also illustrates the use of unit testing to detect newly introduced flaws in the code as it evolves in the software life cycle.

Enjoy and may your Maple skills profit from the experience!

Best regards,

Marko Riedel

The software is also available here: dfam-mult.txt


I am comptuing the eigenvalues and the characteristic polynomial of a 8 by 8 symmetric matrix, say M. Thus, we define the matrix M, and compute its charast. plynm. by



and its eigenvalues with the command



Well, Maple returns the charast. polynm. an dthe eigenvalues. But, if we compute p(E[k]), for k=1,...,8, thats is, the values of the polynomial p(x) in the eingenvalues, Maple not turns cero!!! I'm really confused ... anyone know what could be happening?


Maple attached file with this example. Thank very much for your help!!



hi...amount of Determinant  is infinity?how i can remove this bad calculation ?

how to get maple to do linear algebra in Z_2 (integers modulo 2)

I don't want it to solve and then reduce mod 2 I want it to work over Z_2 so basis([ [1,1,1], [1,-1,1 ]) = [1,1,1]  etc

Hello Everyone


I am new to Maple and I have to find the determinant of the following matrix


Matrix comprising of Bessel Functions whose determinant is to be calculated

Here k is a constant.


Can you please help me with it.


Thanks in advance.


When I calculate the nullspace of a Matrix my solution comes out in a different order than Maple.  So, the question is what steps does Maple use to calculate Nullspace, ColumnSpace, and eigenvalues.  All of these are calculated by Maple in a different order that when I calculate by hand.

What I meant to say is that the answer given by for nullspace is in a different order than if I were do the same calculation by Hand.   

A=<<[1,1,1,1],[1,2,3,4],[4,3,2,1]>>   this is what got calculating the Nullspace by hand <1,-2,1,0>,<2,-3,0,1>  when Maple does the calc. It returns the answer in the opposite order




Is there a way to do the following on Maple:

I want Maple to use Jacobi's method to give an approximation of the solution to the following linear system, with a tolerance of 10^(-2) and with a maximum iteration count of 300.


The linear system is






Exercise Prove that (-1)u = - u in any vector space. Note that (-1)u means the number -1 is multiplied to the vector u, and - u means the negative vector in the fourth property of the definition of vector spaces.


Exercise Prove that (a1u1 + a2u2) + (b1u1 + b2u2) = (a1 + b1)u1 + (a2 + b2)u2 in any vector space.


Exercise Give a detailed reason why, in any vector space,

  • u + v = 0 ⇒ u = - v.

  • 3u + 2v - 4w = 0 ⇒ v = - 3/2 u + 2w.

I wrote down a proceduer in maple for solving integro diff. equations which result in an ill conditioned linear system of algebraic equations. I used the LinearSolve command with method=LU to solve the system but my algorithm failed, and does not converge. Is there any command in maple for solving such systems

let A be a matrix=


[  7        7      9    -17

   6        6      1    -2

 -12    -12    -27    1

   7       7      17   -15 ]

What is the reduced row echelon form of A?

What is the rank of A?

A consistent system of linear equations in 14 unknowns is reduced to row echelon form. There are then 10 non-zero rows (i.e. 10 pivots). How many parameters (free variables) will occur in the solution?

hi fellas
i have questions which maybe very common but i can't handle it right now
there are 9 matrices. each one of them is a 3*3 matrix, not to say all the matrices' elements are in symbolic form.
all i want is to form a matrix made out of the 9 matrices i mentioned above in **maple**; i mean something like "cell" in MatlabI'll be appreciated for your help



how to calculate the first step

(2,0) -> (1,1,1) and (1,4) -> (1,2,0)

how to use maple command to get (1,1,1) and (1,2,0)

how to use maple command to calculate rep(h)


to get (0,-1/2,1) and (1,-1,0)


So im trying to write a maple script that computes the Jordan form of a given (3x3)- matrix
A. If {a,b,c} is a basis with respect to which A is in Jordan form, then I'm trying to make it
plot the three lines spanned by a, b and c, in the standard coordinate system. I was hinted to use plot3d here.

sidenote: I know how to compute the jordan matrix of A, such by find the eigen vectors and generalised eigen vectors and putting them in as columns in a 3x3 matrix say S,   where S is invertible    then  (S^-1)*(A)*(S) = (J).

Thanks in advance. <3

1 2 3 4 Page 1 of 4