[i18n._("Yes"), i18n._("No")] 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 addition 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 for their sum to be defined:

In order for subtraction 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 for their difference to be defined:

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)

Do PRETTY_MAT_1_ID and PRETTY_MAT_2_ID have the same number of rows?

DIM_1 === DIM_3 ? YES : NO

YES NO

Do PRETTY_MAT_1_ID and PRETTY_MAT_2_ID have the same number of columns?

DIM_2 === DIM_4 ? YES : NO

YES NO

Since PRETTY_MAT_1_ID has the same dimensions (DIM_1 + "\\times" + DIM_2) as PRETTY_MAT_2_ID (DIM_3 + "\\times" + DIM_4), PRETTY_MAT_1_ID + OPERATION + PRETTY_MAT_2_ID is defined.

Since PRETTY_MAT_1_ID has different dimensions (DIM_1 + "\\times" + DIM_2) from 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.

How many columns does the first matrix, PRETTY_MAT_1_ID, have?

DIM_2

How many rows does the second matrix, PRETTY_MAT_2_ID, have?

DIM_3

Since PRETTY_MAT_1_ID has the same number of columns (DIM_2) as PRETTY_MAT_2_ID has rows (DIM_3), PRETTY_MAT_1_ID + PRETTY_MAT_2_ID is defined.
Since PRETTY_MAT_1_ID has a different number of columns (DIM_2) than PRETTY_MAT_2_ID has rows (DIM_3), PRETTY_MAT_1_ID + PRETTY_MAT_2_ID is not defined.