WeBWorK Problems

Multiplying Matrices with Entries that are Variables

Multiplying Matrices with Entries that are Variables

by Fabian Gabel -
Number of replies: 1

Hi, 

there are several posts on the topics of having matrices with "variable" entries in this forum, but all date back at least 6 years and none of them helped me with my current problem: Given an upper-diagonal matrix with some entries that are variable I want to multiply this matrix with another one in order to make the calculation of the determinant more challenging:

Context('Matrix')->variables->are('x'=>'Real', 'y'=>'Real', 'z'=>'Real');

foreach $i (0..4) { 
        foreach $j (0..4) {
                $a[$i][$j] = non_zero_random(-9,9,1);
        }   
}

$A = GL4Z();
$Ainv = $A->inverse;
$M = Matrix([[     'x',    'x^2', $a[0][2], $a[0][3]], 
             [       0,      'y',    'y^2', $a[1][3]], 
             [       0,        0,      'z',    'z^3'], 
             [       0,        0,        0, $a[3][3]]]);

$AMAinv = Formula("($A * $M * Ainv)")->reduce;

$ans = Compute("x * y * z * $a[3][3]");

Context()->texStrings;
BEGIN_TEXT
Find the derivative of the function 
\[ f(x) = \det $AMAinv . \]

What do you recommend? Is there another way other than hardcoding the product?

Best wishes, Fabian

In reply to Fabian Gabel

Re: Multiplying Matrices with Entries that are Variables

by Davide Cervone -
The MathObject library is not a computer algebra system (CAS). It does some simplification and things like derivatives, but it is not a general CAS, and doesn't do the kind of matrix multiplication of formulas that you are asking for.

One option is the Sage integration. That provides you access to a full CAS.