This section is devoted to a very important practical tectniques how to extract submatrices and how to build matrices from smaller matrices.
Operations on Vectors
In Maxima, vectors can be represented in a couple of ways, but the most common representation is using square brackets [] to
denote a list, which can be used as a vector.
For example:
Using square brackets:
is the standard way to represent a vector in Maxima. This is the preferred
method for representing vectors because it is directly compatible with Maxima’s vector and matrix operations.
Using parentheses:
represents a sequence in Maxima, not a vector. While sequences can sometimes
be used similarly to vectors, they are not the same and may behave differently in certain contexts.
Column vectors: To create a column vector, you would typically use a matrix with a single column. For example, matrix([1],
[2], [3], [4], [5], [6]) creates a column matrix, which can be treated as a column vector:
Maxima allows a user to make linear combinations.
We can define vectors with entries as functions:
Dot-product is defined as usual:
However, Hadamard product is defined with "*"
We check whether vectors are equal:
The magnitude of a vector u is related to the dot product by way of:
We can define a function for evaluation of the absolute value of a vector
To create vectors with specific types of entries (like even or odd), you would manually specify the entries that meet your
criteria. For example, [2, 4, 6, 8] for even entries, and [1, 3, 5, 7] for odd entries.
There’s no built-in function to automatically generate such vectors, but you can use list comprehension or loops to generate
them programmatically:
To create a vector where each entry is the third consecutive integer starting from 1 (i.e., [1, 3, 6, 9, ...]), you can
use a formula within a list comprehension. For example, you can use the formula n·(n+1)/2 for the n-th term of the sequence and
generate a list based on this:
To create a vector with random entries in Maxima, you can use the random function within a list comprehension or a loop.
For example,
would create a vector of 6 entries where each entry is a random integer
between 0 and 9.
============================= vectors with complex entries
build a new vector (either row or column) from two vectors, say
[1,2] and [3,4]
make one vector: [1, 2, 3, 4]
Similar extract pne entry or subvector from [1, 2, 3, 4, 5]
Partition Matrices
There are many matrix functions available when you start Maxima and these functions can be used without loading in any
additional packages. Here is the list (but several of these – see below – need separate packages loaded) from the Maxima
html Help Manual (In the Help Manual index, type: matrixp, and then click on the category: Matrices, to see this list.)
In Maxima, matrices can be created using the matrix function. The syntax is straightforward: you provide the rows of the matrix
as arguments to the function, with each row being a list of elements.
Maxima also supports symbolic elements, so you can create matrices with variables or expressions.
For example, this creates a 3 × 3 matrix A with the numbers 1 to 9 and a random matrix B:
The following code creates a 3 × 2 random matrix C and a 4 × 3 random matrix D:
Maxima allows you to perform all the basic matrix operations, including addition, subtraction, multiplication, and scalar multiplication. For instance:
Multiplying matrices can be done using the . operator, provided the matrices have compatible dimensions:
Multiplying a matrix by a scalar (a single number) is done using the "*" operator:
The Hadamard multiplication of two matrices is performed with the same command:
============================= matrices with complex entries
The determinant of a square matrix can be evaluated as follows
Transposition could be achived as
The inverse of a square matrix (if it exists)
Extracting Blocks from Matrices
Extracting submatrices is a
powerful technique for focusing on specific parts of a matrix that are relevant to a particular problem.
This can be useful in a variety of contexts, such as solving smaller parts of a larger system of equations, performing
operations on specific sections of data, or simplifying complex calculations.
It returns a new matrix composed of the matrix M with rows
⟨i_1⟩, … , ⟨i_m⟩ deleted, and columns ⟨j_1⟩, … , ⟨j_n⟩ deleted.
Slicing,
on the other hand, is a related concept that involves selecting continuous parts of a matrix, such as a range of rows
or columns. Slicing can be thought of as a more specific form of creating submatrices, where the selection is based on
sequential indices. This is particularly useful in data analysis and processing tasks, where one might need to extract
consecutive rows or columns for further analysis or visualization.
For example, first and second row of the above matrix A:
Also
With second row skipped:
Extracting columns:
In practical terms, both submatrices and slicing are achieved through indexing operations. In a software tool like Maxima, one
might use specific functions or syntax to specify the indices of the rows and columns to be extracted. These operations are
essential for working with large matrices, allowing users to easily manipulate and analyze sections of data.
Row and Column Operations: You can perform operations on specific rows or columns, such as row reduction or applying a
function to every element in a row or column.
Row and column operations are transformations that can be applied to the rows or columns of a matrix. These operations are the
backbone of many algorithms in linear algebra, including those used for solving systems of equations, determining matrix rank,
and performing matrix decompositions.
Common row and column operations include:
Scaling:
Multiplying a row or column by a non-zero scalar. This operation can change the scale of a system of equations without
affecting its solutions:
Replacement:
Adding to one row or column the scalar multiple of another. This is used extensively in the process of row reduction or
Gaussian elimination:
>b>Interchanging:
Swapping two rows or columns. This operation is often used to simplify calculations or to bring a matrix into a more
desirable form, such as when performing pivoting in Gaussian elimination:
In Maxima, there is no direct access to matrix columns. To achieve a similar effect for columns, you need to transpose the matrix,
perform the desired operations on the rows, and then transpose the matrix back once you’re done.
Also all these operations might be performed manually through a series of commands or by utilizing specific functions designed
for linear algebraic manipulations. For example, one could use loops or apply functions to perform operations across an entire
row or column, or use built-in functions to automate common tasks like row reduction.
Example 1: Let us consider the 3-by-4 matrix
Insert a column at position 2: