AI Computer Institute
Expert-curated CS & AI curriculum aligned to CBSE standards. A bharath.ai initiative. About Us

Matrices and Linear Transformations: How AI Transforms Data

📚 Linear Algebra⏱️ 22 min read🎓 Grade 10
✍️ AI Computer Institute Editorial Team Updated: August 2026 CBSE-aligned · Peer-reviewed · 22 min read
Content curated by subject matter experts with IIT/NIT backgrounds. All chapters are fact-checked against official CBSE/NCERT syllabi.

When you unlock your phone with your face, or when an Aadhaar-linked kiosk verifies your identity through a camera, the system is not "looking" at a photograph the way you do. It converts your face into a list of numbers — a vector — and then repeatedly multiplies that vector by matrices. Each multiplication bends, stretches, and rotates the vector inside an abstract space until faces that belong to the same person end up close together and faces of different people end up far apart. The entire recognition system is, underneath the marketing language, a chain of matrices acting on vectors. This chapter is about understanding exactly what that action is, why it has to take the very restricted form it does, and how to compute it by hand and in code.

1. A transformation that looks reasonable but isn't

Consider a rule that takes any point (x, y) in the plane and shifts it 5 units to the right:

T(x, y) = (x + 5, y)

This is a perfectly good function. It is even useful — shifting every pixel of an image sideways is something real software does. But it is not the kind of transformation matrices can represent, and the reason is worth deriving carefully because it tells you exactly what a matrix can do.

A transformation T is called linear if it satisfies two conditions for all vectors u, v and all scalars c:

  • Additivity: T(u + v) = T(u) + T(v)
  • Homogeneity: T(c·u) = c·T(u)

There is a fast necessary test buried inside homogeneity: set c = 0. Then T(0) = T(0·u) = 0·T(u) = 0. Every linear transformation must send the origin to the origin. Check T(x,y) = (x+5, y) against this: T(0, 0) = (5, 0) ≠ (0, 0). The test fails immediately, so T is not linear — it is an affine transformation (linear plus a fixed shift), and affine maps need an extra addition step that a matrix alone cannot supply. You can double-check with the full additivity condition too: take u = (1,0) and v = (1,0). Then T(u) + T(v) = (6,0) + (6,0) = (12, 0), but T(u+v) = T(2,0) = (7,0). Since 12 ≠ 7, additivity genuinely breaks, not just the quick origin test.

Now compare this with scaling every point by 2: T(x,y) = (2x, 2y). Here T(0,0) = (0,0), and you can verify additivity and homogeneity hold for any input. This is linear, and it is exactly the kind of rule a matrix encodes. The restriction to linear maps is not a limitation textbooks impose arbitrarily — it is what makes a transformation representable by a fixed grid of numbers that does not change depending on the input, which is precisely what makes matrix multiplication fast and predictable on hardware.

2. The one idea that generates the entire theory

Here is the fact that makes matrices work at all. Any point (x, y) in the plane can be written as:

(x, y) = x·(1, 0) + y·(0, 1) = x·e1 + y·e2

where e1 = (1,0) and e2 = (0,1) are the standard basis vectors. Now apply a linear transformation T to both sides, using additivity and homogeneity:

T(x, y) = T(x·e1 + y·e2) = x·T(e1) + y·T(e2)

Read that last line slowly — it is the entire theory of matrices in one step. It says: if you know only where T sends the two basis vectors e1 and e2, you know where T sends every single point in the plane. A linear transformation of an infinite plane is completely pinned down by just two output vectors. Those two vectors are exactly what a matrix stores. If T(e1) = (a, c) and T(e2) = (b, d), then T(e1) becomes the first column and T(e2) becomes the second column of the matrix:

A = [ a  b ]
    [ c  d ]

and computing T(x,y) for any point is just the matrix-vector product:

A [x]   [a  b] [x]   [ax + by]
  [y] = [c  d] [y] = [cx + dy]

This is not a coincidence you memorise — it is a direct restatement of x·T(e1) + y·T(e2) written in column form. Every fact you learn about matrices from this point on is a consequence of this one identity.

3. A fully worked example, traced step by step

Let A below act on the four corners of the unit square: (0,0), (1,0), (1,1), (0,1).

A = [ 2  1 ]     i.e.  a=2, b=1, c=0, d=1
    [ 0  1 ]

Because A's columns are exactly T(e1) and T(e2), you can read off immediately that T(1,0) = (2,0) and T(0,1) = (1,1). For the remaining corners, use linearity as derived above:

  • T(0,0) = 0·(2,0) + 0·(1,1) = (0,0)
  • T(1,0) = 1·(2,0) + 0·(1,1) = (2,0)
  • T(1,1) = 1·(2,0) + 1·(1,1) = (3,1)
  • T(0,1) = 0·(2,0) + 1·(1,1) = (1,1)

The square becomes the parallelogram with vertices (0,0), (2,0), (3,1), (1,1) — notice it is genuinely a parallelogram (opposite sides parallel and equal), which is not an accident: a linear map always sends a parallelogram to a parallelogram, because it always sends sums of vectors to sums of their images. The diagram below plots both spaces at consistent scale, with the two basis vectors picked out in colour in each panel so you can see exactly which column of A produced which edge of the output shape.

Input space Output space (after A) x y e1=(1,0) e2=(0,1) A [2 1; 0 1] x y A·e1=(2,0) A·e2=(1,1) Column 1 of A = image of e1 (green) Column 2 of A = image of e2 (red)

Notice the green vector's new length in output space is still the vector (2,0) read directly off column 1 of A, and the red vector is exactly column 2, (1,1). This is the theorem from Section 2 made visible: the whole shape moved because two vectors moved, and the matrix is nothing but a record of where those two vectors went.

4. Rotation matrices: deriving the formula, not memorising it

A rotation by angle θ (counter-clockwise, about the origin) is linear: rotating then adding is the same as adding then rotating, and rotating a scaled vector scales the rotated result by the same factor. So by Section 2, we only need to find where a rotation sends e1 and e2.

Take any point at distance r from the origin, at angle φ to the x-axis. By the definition of sine and cosine, its coordinates are x = r cosφ, y = r sinφ. Rotating it by θ moves it to angle φ+θ, at the same radius r, so the new coordinates are:

x' = r cos(φ+θ)
y' = r sin(φ+θ)

To turn this into something computable from x and y, expand using the compound-angle identities cos(φ+θ) = cosφcosθ - sinφsinθ and sin(φ+θ) = sinφcosθ + cosφsinθ — these are borrowed from Class 11 trigonometry (compound angle formulae), a level ahead of where this chapter otherwise sits, so treat them as a tool you'll formally derive later rather than something to memorise here. Substituting r cosφ = x and r sinφ = y:

x' = x cosθ - y sinθ
y' = x sinθ + y cosθ

Now apply this to the basis vectors specifically. For e1 = (1,0): x'=cosθ, y'=sinθ, so T(e1) = (cosθ, sinθ). For e2=(0,1): x'=-sinθ, y'=cosθ, so T(e2)=(-sinθ, cosθ). Assembling columns:

R(θ) = [ cosθ  -sinθ ]
            [ sinθ   cosθ ]

Sanity check: rotate (1,0) by 90°. cos90°=0, sin90°=1, so R(90°) = [0,-1; 1,0], and R(90°)·(1,0) = (0,1) — exactly where (1,0) should land after a quarter-turn counter-clockwise. The formula was derived, not asserted, and it checks out against something you can visualise directly.

5. Composing transformations: why matrix multiplication is defined the way it is, and why order matters

If you apply transformation S first and then transformation R, the combined effect on a vector v is R(S(v)). Because this combined map is itself linear (composing two linear maps always gives a linear map — you can check additivity and homogeneity survive the composition), it too must correspond to some matrix, and that matrix is exactly the product RS, computed by the standard row-times-column rule. This is why matrix multiplication is defined the seemingly odd way it is in textbooks — it is forced to be, so that "multiply the matrices" and "apply one transformation after another" mean the same thing.

Take the 90° rotation R = [0,-1; 1,0] and a horizontal shear S = [1,1; 0,1] (which sends (x,y) → (x+y, y), i.e. it slants vertical lines sideways in proportion to their height). Compute both orders by hand, column by column, using the rule "each column of the product is the first matrix applied to the corresponding column of the second":

RS: apply S first, then R
  S's columns are (1,0) and (1,1).
  R·(1,0) = (0,1)
  R·(1,1) = (0·1-1·1, 1·1+0·1) = (-1,1)
  RS = [ 0  -1 ]
       [ 1   1 ]

SR: apply R first, then S
  R's columns are (0,1) and (-1,0).
  S·(0,1) = (0+1, 1) = (1,1)
  S·(-1,0) = (-1+0, 0) = (-1,0)
  SR = [ 1  -1 ]
       [ 1   0 ]

RS ≠ SR — rotating-then-shearing is a genuinely different transformation from shearing-then-rotating. This is not a computational quirk; it reflects something true about the physical actions themselves (rotate a sheared square, versus shear a rotated square, and you get different final shapes). Matrix multiplication is non-commutative precisely because composition of transformations is order-dependent. Verify the same computation in code:

import numpy as np

R = np.array([[0, -1], [1, 0]])
S = np.array([[1, 1], [0, 1]])

print(R @ S)
# [[ 0 -1]
#  [ 1  1]]

print(S @ R)
# [[ 1 -1]
#  [ 1  0]]

6. The determinant: how much area a transformation creates or destroys

Go back to A = [2,1; 0,1] from Section 3. The unit square (area 1) became a parallelogram with vertices (0,0),(2,0),(3,1),(1,1). Using the shoelace formula, its area is:

Area = ½|x1(y2-y4) + x2(y3-y1) + x3(y4-y2) + x4(y1-y3)|
     = ½|0(0-1) + 2(1-0) + 3(1-0) + 1(0-1)|
     = ½|0 + 2 + 3 - 1| = ½(4) = 2

The area doubled. Compare this to the quantity ad - bc computed directly from the matrix entries: (2)(1) - (1)(0) = 2. This is the determinant, and it is not a coincidence that it matches — the determinant of a 2×2 matrix is defined precisely to equal the signed area of the parallelogram that the unit square is mapped to. A determinant of 2 means "this transformation doubles area, everywhere, uniformly." A negative determinant would mean area is preserved in magnitude but orientation flips (the square gets mirrored, not just resized).

This has an important extreme case. What happens when the determinant is exactly 0? Take W = [1,2; 2,4]: det(W) = (1)(4)-(2)(2) = 0. Apply it to two different, clearly distinct input points:

W·(1, 0)   = (1, 2)
W·(0, 0.5) = (1, 2)

Two different inputs collapsed onto the exact same output point. A zero determinant always signals this kind of collapse: the transformation squashes the entire 2D plane down onto a single line (or, in worse cases, a single point), and information about which input produced a given output is permanently destroyed — there is no way back. This matrix is called singular (non-invertible), and the reason is structural, not incidental: notice row 2 of W is exactly row 1 doubled, so the two output coordinates are never independent; every output lands on the line y=2x.

7. Why a neural network layer is exactly this

A "dense" or "fully connected" layer in a neural network computes y = Wx (often followed by adding a bias vector and a non-linear function, but the linear core is Wx). Each row of W is one neuron's weight vector, and by the dot-product form of matrix-vector multiplication, that neuron's output is a weighted sum of the inputs — a single number measuring how strongly the input matches that row's pattern.

Take a tiny illustrative case: a 2×2 grayscale image flattened into a 4-number vector x = (top-left, top-right, bottom-left, bottom-right), fed into a layer with two neurons:

import numpy as np

# neuron A detects top-vs-bottom brightness difference
# neuron B detects left-vs-right brightness difference
W = np.array([
    [ 0.5,  0.5, -0.5, -0.5],   # neuron A weights
    [ 0.5, -0.5,  0.5, -0.5],   # neuron B weights
])

x = np.array([0.1, 0.2, 0.1, 0.2])   # top row = bottom row, right side brighter
print(W @ x)
# [ 0.  -0.1]

Trace it by hand for neuron A: 0.5(0.1) + 0.5(0.2) - 0.5(0.1) - 0.5(0.2) = 0.05+0.1-0.05-0.1 = 0. That is correct behaviour: this image's top row exactly equals its bottom row, so there is no top-vs-bottom brightness difference for neuron A to detect, and it fires exactly zero. Neuron B: 0.5(0.1) - 0.5(0.2) + 0.5(0.1) - 0.5(0.2) = 0.05-0.1+0.05-0.1 = -0.1, correctly reporting that the left side (0.1, 0.1) is darker than the right side (0.2, 0.2) by a consistent margin. Each row of W is doing exactly what Section 2 describes: it defines a linear functional (a 1-row transformation) that reduces a 4-dimensional input to a single number along one specific "direction" of interest. A real network layer just stacks hundreds or thousands of such rows, each tuned by training instead of hand-picked, to detect thousands of different patterns simultaneously — but the arithmetic per neuron is nothing beyond what you just traced.

8. Correcting a common misconception

A mistake many students make once they've seen a few examples is to assume every geometrically-reasonable transformation of the plane must be linear, because rotation, scaling, and shearing all are. Section 1 already showed translation is the standard counterexample, but the misconception runs deeper: students often think "linear" just means "keeps straight lines straight." Translation keeps straight lines straight too — it maps every line to a parallel line, and every triangle to a congruent triangle — yet it is not linear, because linearity is specifically about preserving vector addition and scalar multiplication relative to a fixed origin, not merely preserving the "straightness" of the picture. That is precisely why T(0,0)=0 is non-negotiable for a linear map, while it is completely irrelevant to whether a transformation preserves straight lines. Keep the origin-check from Section 1 as your fast, reliable filter whenever you are unsure.

Exam corner

CBSE's NCERT Class 12 syllabus (Chapters 3–4, Matrices and Determinants) is where 2×2 and 3×3 determinants, matrix inverses, and their use in solving linear equations become direct board-exam content — this chapter is building the conceptual foundation a year or two ahead of that, not previewing an imminent board topic. For IIT-JEE and BITSAT, the transformation viewpoint you built here — matrix as "where the basis vectors go," determinant as "area scale factor," singular matrices as "information-destroying collapse" — is exactly the intuition that makes JEE's linear-equations-and-rank questions solvable without rote formula recall. If you're aiming at RMO/INMO or the INSPIRE scholarship track, the composition-is-multiplication argument in Section 5 (deriving why matrix multiplication is defined that way, rather than accepting it as a rule) is the style of "prove it from the definition" reasoning those exams reward over formula application.

Check your understanding

  1. Q: Is T(x,y) = (y,x) (swap the coordinates) linear?
    A: Yes. T(0,0)=(0,0) passes the fast check, and in general T(u+v)=T(u)+T(v) and T(cu)=cT(u) both hold because swapping is applied entrywise, independent of any addition or scaling happening around it.
  2. Q: Write the matrix for the transformation in Q1.
    A: T(e1)=T(1,0)=(0,1) is column 1; T(e2)=T(0,1)=(1,0) is column 2. So the matrix is [0,1; 1,0].
  3. Q: A matrix has determinant −3. What happens to a shape's area and orientation under this transformation?
    A: Area is multiplied by 3 (the magnitude); the negative sign means orientation flips — the shape comes out mirrored.
  4. Q: If matrix M has two identical rows, what can you say about det(M) and about M being invertible?
    A: det(M)=0 (as in Section 6's example with proportional rows), so M is singular/non-invertible — it collapses the plane onto a line, and distinct inputs can map to the same output.
  5. Q: For matrices P and Q, is PQ always equal to QP? Justify using the idea of composition, not just algebra.
    A: No, in general. PQ means "apply Q, then apply P"; QP means "apply P, then apply Q." Doing two geometric operations in opposite orders usually produces different results (Section 5's rotate-then-shear vs shear-then-rotate example), so the two products differ except in special cases.

Summary

A linear transformation is fully determined by where it sends just two vectors, e1 and e2 — and a matrix is nothing more than those two output vectors written as columns. This single fact generates matrix-vector multiplication (Section 2–3), explains why rotation takes the specific cosine/sine form it does (Section 4), forces matrix multiplication to be defined as it is and to be order-sensitive (Section 5), and gives the determinant its meaning as an area-scaling, information-preserving (or information-destroying, when zero) factor (Section 6). A neural network's dense layer is this same y=Wx operation, just with many rows learned from data instead of hand-designed (Section 7). Back to where this chapter started: when a face-recognition system at an Aadhaar-linked kiosk processes your photo, every one of those internal matrices is doing exactly the operation you traced by hand in Section 3 — reading off where a handful of basis directions land, and using linearity to extend that to every possible face vector, layer after layer, until vectors belonging to the same person land close together in the final space.

Think About It

Think about this: How would you explain matrices and linear transformations: how ai transforms data to a friend who has never seen a computer? What real-world analogy would you use? Imagine you had to build a system using these concepts — what would be your first step? Try this: before moving on, write down three things you learned and one question you still have.

Practice Exercises

Now it is time to practice! Complete these challenges to solidify your understanding:

  • Exercise 1: Write a short program that demonstrates the core concept from this chapter. Test it with at least 3 different inputs.
  • Exercise 2: Find a real-world example where matrices and linear transformations: how ai transforms data is used in an Indian company (like TCS, Infosys, Flipkart, or ISRO). Write a paragraph explaining the connection.
  • Exercise 3: Create a mind-map connecting matrices and linear transformations: how ai transforms data to at least 3 other topics you have studied.
← Vectors and Vector Spaces: The Language of AIEigenvalues and Eigenvectors: Finding the Essence of Data →

Found this useful? Share it!

📱 WhatsApp 🐦 Twitter 💼 LinkedIn