DEFINED ? "Yes" : "No" makeMatrix(randRange(-2, 4, DIM_1, DIM_2)) makeMatrix(randRange(-2, 4, DIM_3, DIM_4)) "\\textbf " + randFromArray("ABCDEF") "\\textbf " + randFromArray("ABCDEF") printSimpleMatrix(MAT_1) printSimpleMatrix(MAT_2)

PRETTY_MAT_1_ID = PRETTY_MAT_1

PRETTY_MAT_2_ID = PRETTY_MAT_2

Is PRETTY_MAT_1_ID + OPERATION + PRETTY_MAT_2_ID defined?

ANSWER

randRange(0, 1) randRange(1, 3) randRange(1, 3) DIM_1 DEFINED ? DIM_2 : randRangeExclude(1, 3, [DIM_2]) randFromArray("+-")

In order for additionsubtraction of two matrices to be defined, the matrices must have the same dimensions.

If PRETTY_MAT_1_ID is of dimension (\blue m \times \red n) and PRETTY_MAT_2_ID is of dimension (\blue p \times \red q), then:

1. \blue m (number of rows in PRETTY_MAT_1_ID) must equal \blue p (number of rows in PRETTY_MAT_2_ID) and

2. \red n (number of columns in PRETTY_MAT_1_ID) must equal \red q (number of columns in PRETTY_MAT_2_ID)

for their sumdifference to be defined.

Since PRETTY_MAT_1_ID has the samedifferent dimensions (DIM_1 + "\\times" + DIM_2) asfrom PRETTY_MAT_2_ID (DIM_3 + "\\times" + DIM_4),

PRETTY_MAT_1_ID + OPERATION + PRETTY_MAT_2_ID is not defined.

randRange(0, 1) randRange(1, 3) randRange(1, 3) DEFINED ? DIM_2 : randRangeExclude(1, 3, [DIM_2]) randRange(1, 3) ""

In order for multiplication of two matrices to be defined, the two inner dimensions must be equal.

If the two matrices have dimensions (\blue m \times \red n) and (\red p \times \green q), then \red n (number of columns in the first matrix) must equal \red p (number of rows in the second matrix) for their product to be defined.

Since PRETTY_MAT_1_ID has the samea different number of columns (DIM_2) asthan PRETTY_MAT_2_ID has rows (DIM_3), PRETTY_MAT_1_ID + PRETTY_MAT_2_ID is not defined.