How do you perform matrix addition and subtraction?

Quick Overview

Asks how to add and subtract two matrices, when the operations are defined, and what shape the result takes. Tests basic linear algebra fluency: the rule for combining entries, the algebraic properties of addition, and the shape mistakes that array broadcasting in code can hide.

How do you perform matrix addition and subtraction?

Role: Data Scientist

Category: Statistics & Math

Difficulty: easy

Interview Round: Other

How do you perform matrix addition and subtraction? Explain when the two operations are defined and what shape the result has. ```hint Look at the shapes Before computing anything, compare the dimensions of the two matrices. What has to match for every entry of one matrix to have a partner in the other? ``` ### What a Strong Answer Covers - The condition on the dimensions of the two matrices, and the shape of the result - The entry-wise rule written for a general position $(i, j)$ - A small worked example of both operations - The algebraic properties of addition and how subtraction relates to it - How the shape rule differs from matrix multiplication and from array broadcasting in code ### Follow-up Questions - Why does NumPy let you add a `(3, 1)` array to a `(1, 4)` array, and is that matrix addition? - Is matrix multiplication commutative? Give two matrices where $AB\neq BA$. - What does adding two $m \times n$ matrices cost, and can it be done in place? - How does matrix addition interact with scalar multiplication and with the transpose?

Overview: Asks how to add and subtract two matrices, when the operations are defined, and what shape the result takes. Tests basic linear algebra fluency: the rule for combining entries, the algebraic properties of addition, and the shape mistakes that array broadcasting in code can hide.

Nov 25, 2026
easyData ScientistOtherStatistics & Math
0
0

How do you perform matrix addition and subtraction? Explain when the two operations are defined and what shape the result has.

What a Strong Answer Covers Guidance

  • The condition on the dimensions of the two matrices, and the shape of the result
  • The entry-wise rule written for a general position (i,j)(i, j)
  • A small worked example of both operations
  • The algebraic properties of addition and how subtraction relates to it
  • How the shape rule differs from matrix multiplication and from array broadcasting in code

Follow-up Questions Guidance

  • Why does NumPy let you add a (3, 1) array to a (1, 4) array, and is that matrix addition?
  • Is matrix multiplication commutative? Give two matrices where AB≠BAAB\neq BA .
  • What does adding two m×nm \times n matrices cost, and can it be done in place?
  • How does matrix addition interact with scalar multiplication and with the transpose?