Skip to the lesson
FixTheRobot Explore Robotics / Linear Algebra / M3 Linear Systems and Vector Spaces / M3-T1

Linear Algebra · Theory · M3

M3-T1 — Systems of Linear Equations

A robot problem is a set of constraints. Writing them as A x = b is the first step to deciding whether they can be satisfied, and how.

  • Lesson 1 of 8
  • Module 3: Linear Systems and Vector Spaces
  • Linear systems
  • About 10 minutes to read

Thrust allocation, wheel constraints, calibration equations and measurement models are all systems of linear equations. This lesson shows how to write them as a matrix equation, how to picture them, and how to predict whether they have a unique answer, none, or many.

Learning objectives

After this lesson, you should be able to:

  • Translate a set of linear constraints into the matrix form A x = b.
  • Picture a 2 × 2 system as two lines and a 3 × 3 system as three planes, and read the number of solutions from the picture.
  • Solve a 2 × 2 system by elimination and derive the general formula with its determinant condition.
  • Name the three cases (unique, none, infinitely many) and what each means for a robot.

Introduction and motivation

A quadrotor has four motors and must produce a total thrust and three torques. A mobile base has two wheels and must produce a forward speed and a turn rate. A sensor suite measures several combinations of the same unknown state. In each case the engineering question is the same: given what I want or observed, what values of the unknowns satisfy all the constraints? Linear algebra answers it in a uniform language, and the first step is writing the constraints as A x = b.

The intuition

Each linear equation cuts down the freedom of the unknowns. One equation in two unknowns, like x + 2y = 4, is satisfied by a whole line of points. A second equation draws another line, and a point satisfies both equations only if it lies on both lines, that is, at the crossing.

Lines in the plane do one of three things: cross in a single point (one solution), run parallel without meeting (no solution), or lie on top of each other (infinitely many). The same trichotomy holds for any number of equations and unknowns: the answer is always zero, one or infinitely many solutions, never exactly two.

Interactive figure. Two straight lines, one for each equation. Where they cross is the solution. Parallel lines mean no solution and identical lines mean infinitely many. The readout gives the determinant and the number of solutions. This figure needs JavaScript to be interactive.

Change the coefficients and watch the two lines. Make them parallel to lose the solution, then make them identical to get infinitely many.
Allocating thrust between two rotorsA two-rotor aircraft model. The total thrust is the sum of the rotor thrusts and the torque is the arm length times their difference. Written as a matrix equation, it has a unique solution when the matrix is invertible.11−0.30.3A ×F₁F₂x (unknowns) =100.6b (demands) F₁ + F₂ = 10 (total thrust, N) −0.3 F₁ + 0.3 F₂ = 0.6 (torque, N·m) Solution: F₂ − F₁ = 2, so F₁ = 4 N and F₂ = 6 N. One equation per demand; one unknown per actuator.
Two actuators, two demands: the constraints written as A x = b. The solution 4 N and 6 N is read off by elimination.

Geometric and physical interpretation

Geometric view. Each equation a x + b y = c is a line; each equation a x + b y + c z = d is a plane. The solution set is where all of them intersect: a point, a line, a plane, or nothing. Physical view. Each equation is a physical requirement: the rotors must add up to the commanded thrust, the wheels must not slip sideways, the sensors must agree with the state. A solution is a set of actuator or state values that satisfies every requirement at once. If you demand too many things the requirements can contradict each other, and the system has no solution.

The mathematics

x
the vector of unknowns x₁, …, xn.
A
the m × n coefficient matrix: row i holds the coefficients of equation i.
b
the vector of right-hand sides (the demands or measurements), with m entries.
m, n
the number of equations and the number of unknowns.

Matrix form

a11 x1 + a12 x2 + ... + a1n xn = b1
  ...
am1 x1 + am2 x2 + ... + amn xn = bm              ⇔         A x = b

What it means. Stacking m equations in n unknowns into one equation A x = b. Each row of A is one constraint; the product Ax computes all the left-hand sides at once, so the system says “find x such that these m combinations equal these m demands”.

The three cases

exactly one solution    |    no solution    |    infinitely many solutions

What it means. If two different solutions existed, every point on the line through them would be a solution as well (their combinations satisfy the equations by linearity), so there can never be exactly two.

2 × 2: when is the solution unique?

x = (c1 b2 − c2 b1) / (a1 b2 − a2 b1)        y = (a1 c2 − a2 c1) / (a1 b2 − a2 b1)

What it means. The denominator is the determinant of A. A unique solution exists exactly when det A ≠ 0, that is when the two lines are not parallel. When det A = 0 there are either no solutions or infinitely many.

Write constraints as A x = b. The solution set is the intersection of the constraints: a point, a line, a plane or nothing.

Step-by-step derivation: solving two equations by elimination

Take a₁x + b₁y = c₁ and a₂x + b₂y = c₂. Eliminate y first.

  1. Multiply the first equation by b₂ and the second by b₁: a₁b₂ x + b₁b₂ y = c₁b₂ and a₂b₁ x + b₁b₂ y = c₂b₁.
  2. Subtract the second from the first: the y terms cancel, leaving (a₁b₂ − a₂b₁) x = c₁b₂ − c₂b₁.
  3. If a₁b₂ − a₂b₁ ≠ 0 divide to get x = (c₁b₂ − c₂b₁)/(a₁b₂ − a₂b₁).
  4. Eliminate x the same way (multiply by a₂ and a₁ and subtract) to get (a₁b₂ − a₂b₁) y = a₁c₂ − a₂c₁, hence y = (a₁c₂ − a₂c₁)/(a₁b₂ − a₂b₁).
  5. The degenerate case. If a₁b₂ − a₂b₁ = 0, the left side of step 2 is zero for every x, so the equation reads 0 = c₁b₂ − c₂b₁. If the right side is not zero this is false and there is no solution; if it is zero the equation holds for every x and there are infinitely many solutions.

The denominator is the determinant of the coefficient matrix, so the determinant decides uniqueness. This anticipates a general principle: a square system has a unique solution exactly when its matrix is invertible.

Why never exactly two solutions. If x₁ ≠ x₂ both solve A x = b, then for any number t, A(x₁ + t(x₂ − x₁)) = (1 − t)Ax₁ + tAx₂ = (1 − t)b + tb = b. So the whole line through x₁ and x₂ solves the system: either there is at most one solution or there are infinitely many.

A worked example: thrust allocation, and a general 2 × 2 system

Thrust allocation. Two rotors, each at distance 0.3 m from the centre, must produce total thrust 10 N and torque 0.6 N·m about the centre. With rotor thrusts F₁, F₂: F₁ + F₂ = 10 and −0.3F₁ + 0.3F₂ = 0.6.

  1. Matrix form. A = [[1, 1], [−0.3, 0.3]], x = (F₁, F₂), b = (10, 0.6).
  2. Determinant. det A = 1·0.3 − 1·(−0.3) = 0.6 ≠ 0, so the solution is unique.
  3. Solve. The second equation divided by 0.3 gives F₂ − F₁ = 2. With F₁ + F₂ = 10, add: 2F₂ = 12, so F₂ = 6 N and F₁ = 4 N.
  4. Check. 4 + 6 = 10 and −0.3·4 + 0.3·6 = 0.6. ✓

A general system. x + 2y = 4 and 3x − y = 2: det = 1·(−1) − 3·2 = −7, x = (4·(−1) − 2·2)/(−7) = 8/7 ≈ 1.143 and y = (1·2 − 3·4)/(−7) = 10/7 ≈ 1.429. Check in the first equation: 8/7 + 20/7 = 28/7 = 4. ✓ The two lines cross at (1.143, 1.429), as in the figure.

The other two cases. x + 2y = 4 and 2x + 4y = 8 describe the same line (infinitely many solutions, det = 0). x + 2y = 4 and 2x + 4y = 9 are parallel (no solution, det = 0).

Robotics application

Actuator allocation. Mapping desired thrust and torques to motor commands is a linear system; the matrix is called the mixer. Four motors for four demands give a square system; more motors than demands (an over-actuated UAV) give infinitely many solutions, from which the flight controller must pick one (Module 5 and Module 6).

Wheel constraints. A differential-drive wheel cannot slide sideways, which is a linear constraint on the body velocity. A mobile base with such constraints cannot move in every direction instantaneously; the navigation track discusses what this means in terms of rank and in its lesson on robot motion models.

Sensor equations. If sensor i reports a known combination of the unknown state, z = H x, then estimating x from z is a linear system. With exactly as many independent sensors as unknowns it has one solution; with fewer, infinitely many (the state is not observable); with more and noisy ones, none exactly, which is why Module 5 introduces least squares. See the error-state Kalman filter for the estimation setting.

Calibration. Each known point pair gives constraints on the unknown entries of a calibration matrix; collecting enough of them yields a linear system whose solvability decides whether the calibration is determined.

Engineering implications and limitations

Practical rules

  • Count equations and unknowns first. More unknowns than equations (m < n) means there are infinitely many solutions or none; more equations than unknowns (m > n) usually means none unless the data are exactly consistent. Do not assume “square” without checking.
  • Real measurements are noisy. Noisy data make an overdetermined system inconsistent: no x satisfies every equation. Do not treat that as a bug in the arithmetic; it signals that you need least squares.
  • Mind units and scaling. Equations mixing metres and radians, or newtons and newton-metres, are legitimate but badly scaled. Scale rows so entries are comparable before solving.
  • A zero determinant is a design problem, not a rounding problem. If the thrust-allocation determinant is zero, the actuators genuinely cannot produce all the demands; fix the design or the demands.
  • Use a solver, not Cramer's rule. The determinant formula above is for understanding; solve numerically with elimination (next lessons).

Limits

Linear systems model situations where constraints combine additively. Saturating motors, friction cones and joint limits are inequalities and nonlinearities; they are handled by adding constraints on top of, not instead of, the linear core described here.

Common misconceptions

“A system always has a solution if I have enough equations.”

More equations make solutions rarer, not more likely: every extra independent equation must be consistent with the others. Noisy extra measurements usually make the system inconsistent.

“If there are more unknowns than equations, there are no solutions.”

There are usually infinitely many (unless the equations contradict each other). That is the situation of a redundant robot.

“A system can have exactly two solutions.”

Never. By linearity, two solutions imply a whole line of them.

“Solving A x = b means computing A⁻¹.”

The inverse exists only for square, non-singular matrices and is a poor way to solve numerically. Elimination solves the system directly and reveals the cases of no or many solutions as well.

Engineering takeaways

  1. A set of m linear constraints on n unknowns is the matrix equation A x = b.
  2. Geometrically the solution set is the intersection of lines (2D) or planes (3D): a point, a line, a plane or empty.
  3. A linear system has zero, one or infinitely many solutions, never exactly two.
  4. For a 2 × 2 system the determinant of A decides uniqueness: det ≠ 0 gives one solution.
  5. Counting equations against unknowns, and checking consistency, is the first diagnostic for any actuator, constraint or calibration problem.

References and further reading

Primary papers and authoritative documentation.

Knowledge check

Three conceptual questions. Write an answer, then reveal the explanation. Your answers stay in your browser.

Question 1

A quadrotor mixer maps four motor thrusts to total thrust and three torques, so A is 4 × 4. If det A = 0, what does that say about the aircraft, and why is it not just a numerical problem?

Explanation

A zero determinant means the four columns (the effect of each motor on the four demands) are linearly dependent: some combination of motors does nothing to the demands, and some demand combinations cannot be produced at all. That is a property of the physical layout (for example two motors producing the same effect), so no solver can fix it; the design or the set of demands must change.

Question 2

The system x + y = 2, 2x + 2y = 5 is posed by a calibration routine. How many solutions does it have, and what does the answer tell you about the data?

Explanation

The coefficient matrix [[1, 1], [2, 2]] has determinant 0 (the lines are parallel), and the right side is inconsistent: twice the first equation would give 2x + 2y = 4, not 5. So there is no solution. For measured data this indicates contradictory measurements (noise or an error), the situation least squares is designed to handle.

Question 3

Three sensors measure combinations of two unknown position coordinates, giving three equations in two unknowns that are perfectly consistent. How many solutions can there be, and what changes if the measurements carry noise?

Explanation

If the equations are consistent and the coefficient matrix has two independent columns there is exactly one solution (any extra consistent equation is redundant). With noise, the three equations generally no longer agree, so no exact solution exists and one looks for the best approximate one, the least-squares solution of Module 5.

What’s next

You can write a system and predict how many solutions it has. Next you will learn the systematic procedure that solves any system by hand or by machine: Gaussian elimination.

Practice this lesson

Solve a Robot's Constraints

A mobile base has wheel and speed constraints: solve for the commands, and handle systems with no solution or many.

Next lesson

M3-T2 — Gaussian Elimination and Row Reduction

Solve a system by elimination with pivoting and read the outcome from the reduced form.

Nothing below is required to finish this lesson.

  • Before
    M2-T7: Inverse Matrices

    Find the inverse of a matrix, say when none exists, and use it to undo a transformation or solve a small system.

  • Lab
    M3-L1: Solve a Robot's Constraints

    A mobile base has wheel and speed constraints: solve for the commands, and handle systems with no solution or many.