## 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, $a], [ 0, 'y', 'y^2',$a],
[       0,        0,      'z',    'z^3'],
[       0,        0,        0, $a]]);$AMAinv = Formula("($A *$M * Ainv)")->reduce;

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

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 