Q1. Scenario: In a warehouse, you have two matrices: A (products × storage locations) shows current stock, and B (storage locations × delivery trucks) shows how many items each truck can take from each location. How do you compute the total items each truck can pick from all products?
This is matrix multiplication: C = A * B. The result C[product][truck] gives the number of items of that product that the truck can collect (through all locations). Matrix multiplication is used in supply chain optimization, where rows represent sources, columns represent destinations, and the product represents total flow.
Q2. Scenario: You are training a neural network with one hidden layer. The input is a vector x (size 256), the weight matrix W (size 128×256), and bias b (size 128). What operation produces the hidden layer activations?
The hidden layer pre-activation is z = W·x + b. Here W·x is matrix-vector multiplication: each row of W dot x gives one element of z, then add bias. This is followed by activation function like ReLU. This operation is the core of forward propagation in deep learning.
Q3. Scenario: You have two matrices: A (2×3) and B (3×2). Can you multiply them in both orders? What are the resulting dimensions?
A (2×3) * B (3×2) is valid and produces a 2×2 matrix. B (3×2) * A (2×3) is also valid and produces a 3×3 matrix. Matrix multiplication is not commutative; the order matters. This is important in transformations: applying scale then rotate vs rotate then scale gives different results.
Q4. Scenario: In a linear regression model, you have feature matrix X (n samples × m features) and weight vector w (m × 1). Predictions = X·w. If you add a constant term (bias), how do you incorporate it using matrix multiplication?
Add a column of ones to X (making it n × (m+1)) and extend w with the bias term. Then predictions = X_augmented · w_extended. This is a common trick to handle intercept efficiently without separate addition.
Q5. Scenario: In a simple 2D graphics system, you have a translation vector [tx, ty] and a point [x, y]. How can you represent translation using matrix multiplication (without separate addition)? Use homogeneous coordinates.
Use 3D homogeneous coordinates: represent point as [x, y, 1]. Translation matrix T = [[1,0,tx],[0,1,ty],[0,0,1]]. Then T · [x,y,1]^T = [x+tx, y+ty, 1]. This unifies translation and rotation into matrix multiplication, crucial in computer graphics and robotics.
