key: cord-0058894-4a8ev7c0 authors: Castillo-Labán, Karina F. M.; Ipanaqué-Chero, Robert title: Extending Maxima Capabilities for Performing Elementary Matrix Operations date: 2020-08-24 journal: Computational Science and Its Applications - ICCSA 2020 DOI: 10.1007/978-3-030-58799-4_30 sha: 7673f3ac46f275bfd7eb2bde54bcde8378e0e074 doc_id: 58894 cord_uid: 4a8ev7c0 The elementary operations on matrices are of great importance and utility since they are applied in obtaining the so-called equivalent matrices, which are related to each other in many important attributes. In this paper we describe a new package for dealing with the elementary matrix operations of a given matrix. The package, developed by the authors in the freeware program Maxima, version 5.43.2, incorporates two commands which have a fairly intuitive syntax and allow the user indicating one or more elementary operations together so that they are applied to the rows (or columns) of a given matrix. Such features make it more effective and friendly than the default built-in commands in Maxima to perform such operations. In addition, our outputs are consistent with Maxima’s notation. Several illustrative examples, aimed to show the good performance of the package, are also given. In addition to the usual operations defined in the M m×n set: addition, multiplication of a scalar, multiplication, and transposition, there are operations that are performed between the elements of some rows or columns of a matrix, called elementary operations. These operations are of great importance and utility because the application of one or more of them allows obtaining certain matrices called equivalent matrices. These matrices, due to their characteristics, are related to each other in many important attributes such as: range, determinant, solution of a system of linear equations and linear combination. And, of course, when considering an augmented matrix, they allow us to obtain the inverse of said matrix [8] . Regarding the inverse of a matrix, there is a very similar method and, more importantly, a "spirit" of methodology that also uses elementary matrix operations on rows and columns, but specializes in certain types of matrices [6, 7] . Calculating elementary matrix operations can be tedious when they are of order m × n, such that m, n > 3. Furthermore, there is a growing concern to develop commands (in Maple [10] , Mathematica [11] , MatLab [9] , Maxima [4] , etc.), applications (in Java [1, 5] ) and programs (Linear Algebra Decoded [12] ) specialized in automating such calculation. What has been expressed in the previous paragraphs, the fact that Maxima includes four commands (with two well-marked flaws: the syntax is not intuitive and they do not allow to indicate several operations together) and the fact that the Maxima is distributed under the GPL [14] license has been reason enough to choose it as the programming language in which to develop a new package in Maxima. This package, which dealing with the elementary matrix operations of a given matrix, is described in this paper. The package, developed by the authors in the freeware program Maxima, version 5.43.2, incorporates two commands which have a fairly intuitive syntax and allow the user indicating one or more elementary operations together so that they are applied to the rows (or columns) of a given matrix. The outputs obtained with the built-in commands in the new package are consistent with the Maxima syntax. Several illustrative examples will be discussed later on in order to show the good performance of the package. The rest of this paper is organized as follows: Sect. 2 outlines concepts related to elementary operations with the rows (columns) of a given matrix. Then, Sect. 3 describes the main standard Maxima tools for performing elementary matrix operations. And Sect. 4 describes the new package. Finally, the conclusions are in Sect. 5. When making calculations with matrices (calculation of inverse, determinant, range, etc.), the operations of the following type are especially important: 1. Swap two rows (or columns). 2. Add a multiple of another row (or column) to one row(or column). 3. Multiply a row (or column) by a non-zero scalar. They are simple operations, which conserve certain quantities associated with the matrix in which they are operated (example: the range) or modify them in a controlled way (example: the determinant). It will be useful to use adapted notations to describe the elementary operations that are done on rows. R i ↔ R j (remark: it will be used only for i = j). 2. Add to row i row j multiplied by scalar λ: (remark: it will be used only for i = j). Changing the R by the C in previous list, the notations to describe the elementary operations that are done on columns are obtained. Maxima includes the linearalgebra package, one of whose commands is rowop (similarly includes the columnop command) [4] . The syntax for this command is: And it works like this: if M is a matrix, it returns the resulting matrix after doing the operation: if M does not have a row i or j, it returns an error message. using the method of elementary operations on rows [2] with the assistance of Maxima. (%i4) AI:rowop(AI,3,1,2); ⎞ ⎠ Therefore, using the method of elementary operations on rows with the assistance of Maxima. Solution 2. Let's form the matrix (A|I) and stored it in the variable AI: Now, let's do: ? The rowop command does not allow this operation. The rowop syntax is not intuitive, since (1) and (2) are not very similar. Remark 2. The transformations λ · R i → R i must be expressed in the form: The built-in columnop and columnswap commands present the same difficulties. As shown in the previous section, the rowop command (just like the columnop command) has certain limitations. However, this does not happen with the commands incorporated in the package developed by the authors: (%i15) load(matop)$ which includes the commands: to perform elementary operations on the rows and columns of a given matrix, M . For both commands it is possible to indicate several operations at the same time. using the method of elementary operations on rows [2] with the assistance of the new Maxima package. Now, let's do: Remark 8. In cases like this it is not possible to indicate all the operations because the variable that stores the matrix must be updated immediately after operating a whole row of the matrix. Example 7. Microsoft manufactures electronic circuit boards for PCs. Each fax-modem, data compression, and sound synthesizer board requires a certain amount of machine time to insert, solder, and assemble the chips. These data (in minutes) together with the number of minutes of machine time available for each operation are summarized in Table 1 . The profit for each board is $20, $15 and $10 respectively. How many boards of each type must be manufactured to maximize Microsoft's profit, if at least 300 data understanding boards are required to be produced? Maximize: Subject to: After standardizing we obtain: 4X 1 + 2.5X 2 + 2X 3 + S 1 = 5000, 2X 1 + 6X 2 + 4X 3 + S 2 = 4200, 1.5X 1 + 2X 2 + 2.5X 3 + S 3 = 2400, Now we proceed to build the first scheme associated with the model as shown in Fig. 1 . Let A be the matrix associated with the model, note that Since −M − 15 is the smallest value of Z − C and 300/1.0 = 300.0 is the smallest quotient of those obtained by dividing, one by one, the elements of D and X 2 , then 1.0 is the pivot. And A 1 is replaced by X 2 . Now, we define the matrix associated with example 7 and then perform the elementary operations on the respective rows, taking the pivot as a reference. Figure 2 shows the update of the first scheme associated with the example 7 (second scheme). Since −20 is the smallest value of Z − C and 4250.0/4.0 = 1062.5 is the smallest quotient obtained after dividing, one by one, the elements of D and X1 (note that divisions by zero are discarded), then 4.0 is the new pivot and S 1 is replaced by X 1 . Next, on the equivalent matrix (previously obtained), we perform the respective elementary operations on the equivalent matrix associated with the model. Since − 5 2 is the smallest value of Z −C and 275.0/4.75 ≈ 57.89 is the smallest quotient obtained after dividing, one by one, the elements of D and X1 (note that negative values are discarded), then 4.75 is the new pivot and S 2 is replaced by S 4 . Next, on the equivalent matrix (previously obtained), we perform the respective elementary operations on the equivalent matrix associated with the model. Since Z i − C i > = 0, the solution is optimal. Therefore, we conclude that: Z max ≈ 25894.7 , X 1 ≈ 1026.32 , X 2 ≈ 357.895 , X 3 = 0 . This paper presents the new matop package that incorporates intuitive rowoper and columnoper commands to perform elementary operations on the rows and columns of a given matrix, respectively. Through examples, the paper shows the ways to indicate the elementary operations. All the examples show the proper functioning of the package; as well as the consistency of the results obtained with the Maxima syntax. All the programming has been developed and coded by the authors in version 5.43.2 of the freeware program Maxima [13] using programming based on transformation rules, comparison patterns [3] and optimized code. Additionally, considering that the command can be easily implemented in other scientific programs that offer capabilities similar to those of Maxima, it would be interesting to do similar research on those programs in the near future. Problemas de las Matemáticas Superiores I Recursive numerical recipes for the high efficient inversion of the confluent Vandermonde matrices Incremental numerical recipes for the high efficient inversion of the confluent Vandermonde matrices Elementary Linear Algebra, 6th edn Nibcode Solutions Manual de Maxima Wikipedia The authors would like to thank to the reviewers for their valuable comments and suggestions.