As we saw in the previous section, creating and manipulating matrices is quite easy and natural in Julia. This section will show how to perform a number of basic Linear Algebra tasks.
DimensionMismatch: incompatible dimensions for matrix multiplication: tried to multiply a matrix of size (3, 4) with a matrix of size (3, 4). The second dimension of the first matrix: 4, does not match the first dimension of the second matrix: 3.
then the determinant of this can be found with det(A) returning -1.0658141036401493e-14.β1β
Note that even though the matrix A is an integer matrix, then the determinant is a floating-point number although the result will be an integer. This has to do with the way that the algorithm uses floating points in the calculation.
The related operation of the adjoint of the matrix combines the transpose and the complex conjugate. If the matrix is real, the adjoint and transpose are identical and is often used because the operation ' is used. For example, A' returns
where the upper left element is very close to zero due to numerical errors. Note that the inverse is a floating-point matrix even though the original matrix is an integer matrix. This is because the inverse is calculated using floating-point arithmetic.
It is often nice to have the inverse in terms of rational numbers. To accomplish this, we need to rationalize the matrix A. This can be one with rationalize.(A) and if the inverse of that is found with inv(rationalize.(A)) resulting in