Often you will have several variables which are related to each other and several equations describing those relationships.
E.g. two coffees and a tea cost £5, three coffees and five teas cost £11, how much is a coffee and how much is a tea? This can be translated into equations to make the pair of equations in \(c\) (the cost of a coffee) and \(t\) (the cost of a tea)
which can be solved to show that a coffee costs £2 and a tea £1.
This can be seen graphically by plotting the two equations for the price of coffee and tea on the same graph.
5.1 Linear equations
There are two methods which are generally used to solve simultaneous equations — elimination and substitution. The goal in both cases is to produce an equation with just one of the unknown variables.
5.1.1 Elimination
One of the fundamental rules of solving equations of any sort is that whatever you do to one side you must do to the other. The elimination method uses this by adding or subtracting equations — since, by definition, both sides of an equation are equal, when we add or subtract one equation from a second equation, we are adding or subtracting the same thing from both sides, even if it doesn’t look like that.
E.g. adding \(x + 3y = 8\) to \(x + y = 6\) gives \(2x + 4y = 14\)
The example is perfectly correct maths, but hasn’t helped us reach our goal of having an equation with just one unknown in it. However, if we subtract the second equation from the first, we get
\[\begin{align}
& & x + 3y &= 8 \\
-\qquad & & x + y &= 6 \\
=\qquad & & 2y &= 2
\end{align}\]
We have now eliminated the \(x\) and have an equation just in \(y\) which can be solved giving \(y=1\). Having solved for \(y\) we can now substitute it into either equation to get \(x\). In this case the second equation is easier — we get \(x + 1 = 6\) which means \(x = 5\).
This was a very straightforward example, as we only had one \(x\) in each equation. Most simultaneous equations are more complicated, for example:
\[\begin{align}
2x + 5y &= 15 \\
x + y &= 6
\end{align}\]
In this case we can eliminate \(x\) by multiplying the second equation by 2, giving us a new equation \(2x + 2y = 12\). The system of equations can then be solved the same way as before:
Our first step is to decide which variable to eliminate — it doesn’t matter which. Let’s go for \(x\) here.
In the first equation the coefficient of \(x\) is 2 and in the second equation it is 3. The lowest common multiple1 of 2 and 3 is 6, so we would like to multiply the equations so the coefficient of \(x\) is 6 in each equation. That means multiplying the first equation by 3, and the second by 2, giving us:
Rearrange both equations in the form \(ax + by = c\) if necessary.
Write the equations one above the other.
Decide which variable to eliminate.
Find the lowest common multiple of the coefficients of that variable in the two equations.
Multiply each equation to make the coefficients of the variable to be eliminated the same in each equation.
Subtract one equation from the other to eliminate the variable.
Solve the resulting equation for the remaining variable.
Substitute the value just found back into one of the equations to solve for the eliminated variable.
Put both values into the other equation to double check — this is not essential, but highly recommended!
5.1.2 Substitution
The other main method to solve simultaneous equations is to use one of the equations to find an expression for one variable, and then substitute it into the other equation.
E.g.
\[\begin{align}
2x + 5y &= 15 \\
x + y &= 6
\end{align}\]
Instead of subtracting the second equation from the first, we can solve it for \(x\) to give
\[x = 6 - y\]
This can then be substituted into the first equation and solved:
There are fewer steps in this method than elimination, but the algebra can be more involved.
5.2 Linear and quadratic equations
The last section dealt with two linear simultaneous equations, and the two most common ways to solve them. Not all equations, however, are linear. Imagine trying to solve
\[\begin{align}
y &= x + 1 \\
y &= x^2 -4x + 5
\end{align}\]
This can be examined graphically:
and it is clear that there are two solutions. The easiest way to solve is to use substitution. Substituting the linear equation into the quadratic, gives us:
\[ x + 1 = x^2 -4x + 5 \]
which can be solved in the same way as any quadratic equation:
which gives us \(x = 1\) and \(x = 4\). Substituting into the linear equation gives \(y = 2\) and \(y = 5\) respectively, so the solutions are: \((1,2)\) and \((4,5)\).
5.3 Linear equations and the equation of a circle
The last section looked at where a line and a parabola cross. Another common case is a line and a circle. E.g.
Just as in the quadratic equation case, the easiest way to tackle this is via substitution:
Rearrange the linear equation to make \(y\) (or \(x\) — it doesn’t matter which) the subject \[ y = {(3x+5) \over 4} \]
Substitute it into the second equation \[ x^2 + \left( {(3x+5) \over 4} \right)^2 -2x -4\left( {(3x+5) \over 4} \right) = 20\]
Simplify \[ x^2 -2x -15 = 0\]
Solve \[ x = -3\qquad \mathrm{or}\qquad x = 5\]
Put the solutions for \(x\) back into the linear equation to get \(y\), and thus the coordinates of the solutions \[ (-3, -1)\qquad \mathrm{and}\qquad (5,5)\]
5.4 Exploring simultaneous equations
The solutions of a pair of simultaneous equations are the points where their graphs cross. Choose the kind of system, then change the numbers in the equations and watch how the crossing points move. Each kind starts with the example from this chapter.
Things to try:
With two lines, make the lines parallel (for example \(x + y = 6\) and \(2x + 2y = 3\)). How many solutions are there? What happens if the second equation is just a multiple of the first, like \(2x + 2y = 12\)?
With a line and a parabola, move the line up or down until it just touches the parabola. What is the discriminant then?
With a line and a circle, find a line that misses the circle completely.
sBlue ="#2780e3"sOrange ="#e8590c"// Inputs.range only labels its number box, so name each slider for screen readers too.labelRanges = (form) => { form.querySelectorAll("input[type=range]").forEach((r) => {const label = r.closest("div")?.parentElement?.querySelector("label")?.textContent;if (label) r.setAttribute("aria-label", label); });return form;}sRange = (extent, value, step, label) => Inputs.range(extent, {value, step, label})viewof sMode = Inputs.radio(["Two straight lines","A line and a parabola","A line and a circle"], {label:"System",value:"Two straight lines"})
viewof sp =labelRanges(sMode ==="Two straight lines"? Inputs.form({a1:sRange([-5,5],1,1,"a₁ (x in equation 1)"),b1:sRange([-5,5],3,1,"b₁ (y in equation 1)"),c1:sRange([-12,12],8,1,"c₁ (right-hand side 1)"),a2:sRange([-5,5],1,1,"a₂ (x in equation 2)"),b2:sRange([-5,5],1,1,"b₂ (y in equation 2)"),c2:sRange([-12,12],6,1,"c₂ (right-hand side 2)")}): sMode ==="A line and a parabola"? Inputs.form({m:sRange([-5,5],1,0.5,"m (gradient of the line)"),k:sRange([-10,10],1,0.5,"k (where the line crosses the y axis)"),p:sRange([-6,6],-4,1,"p (x term of the parabola)"),q:sRange([-10,10],5,1,"q (constant term of the parabola)")}): Inputs.form({m:sRange([-4,4],0.75,0.25,"m (gradient of the line)"),k:sRange([-10,10],1.25,0.25,"k (where the line crosses the y axis)"),h:sRange([-5,5],1,1,"x-coordinate of the centre"),j:sRange([-5,5],2,1,"y-coordinate of the centre"),r:sRange([0.5,8],5,0.5,"r (radius)")}))
sFmt = (x, places =3) => {const p =10** places;const r =Math.round(x * p) / p;return (Object.is(r,-0) ?0: r).toString().replace("-","−");}// "3x", "−x", "+ 4y" etc. for writing equationssTerm = (coef, v, first) => {if (coef ===0) return"";const sign = coef <0? (first ?"−":" − ") : (first ?"":" + ");const mag =Math.abs(coef);return sign + (mag ===1&& v !==""?"":sFmt(mag)) + v;}sLinear = (a, b, c) => {const lhs =sTerm(a,"x",true) +sTerm(b,"y", a ===0);return (lhs ===""?"0": lhs) +" = "+sFmt(c);}sLineY = (m, k) =>"y = "+ ((sTerm(m,"x",true) +sTerm(k,"", m ===0)) ||"0")// Solve x² + Bx + C = 0 style quadratics (with leading coefficient A).sQuadRoots = (A, B, C) => {const D = B * B -4* A * C;if (Math.abs(D) <1e-9) return {D:0,xs: [-B / (2* A)]};if (D <0) return {D,xs: []};return {D,xs: [(-B -Math.sqrt(D)) / (2* A), (-B +Math.sqrt(D)) / (2* A)]};}sys = {if (sMode ==="Two straight lines") {const {a1, b1, c1, a2, b2, c2} = sp;const det = a1 * b2 - a2 * b1;const bad1 = a1 ===0&& b1 ===0, bad2 = a2 ===0&& b2 ===0;let kind, points = [];if (bad1 || bad2) kind ="notline";elseif (det !==0) { kind ="one"; points = [{x: (c1 * b2 - c2 * b1) / det,y: (a1 * c2 - a2 * c1) / det}]; } else {// Parallel: the same line only if equation 2 is a multiple of equation 1. kind = (a1 * c2 === a2 * c1 && b1 * c2 === b2 * c1) ?"same":"parallel"; }return {kind, det, points}; }if (sMode ==="A line and a parabola") {const {m, k, p, q} = sp;// x² + px + q = mx + k => x² + (p − m)x + (q − k) = 0const B = p - m, C = q - k;const {D, xs} =sQuadRoots(1, B, C);return {B, C, D,points: xs.map((x) => ({x,y: m * x + k}))}; }const {m, k, h, j, r} = sp;// (x − h)² + (mx + k − j)² = r² => (1 + m²)x² + 2(m(k − j) − h)x + h² + (k − j)² − r² = 0const A =1+ m * m, B =2* (m * (k - j) - h), C = h * h + (k - j) **2- r * r;const {D, xs} =sQuadRoots(A, B, C);return {A, B, C, D,points: xs.map((x) => ({x,y: m * x + k}))};}
{const L =10;// End points of the line ax + by = c across the plotting area (handles vertical lines).const segment = (a, b, c) => {if (a ===0&& b ===0) return [];if (Math.abs(b) >=Math.abs(a)) return [{x:-L,y: (c + a * L) / b}, {x: L,y: (c - a * L) / b}];return [{x: (c + b * L) / a,y:-L}, {x: (c - b * L) / a,y: L}]; };const marks = [Plot.ruleX([0], {strokeOpacity:0.5}), Plot.ruleY([0], {strokeOpacity:0.5})];let first, second;if (sMode ==="Two straight lines") { first =segment(sp.a1, sp.b1, sp.c1); second =segment(sp.a2, sp.b2, sp.c2); marks.push(Plot.line(first, {x:"x",y:"y",stroke: sBlue,strokeWidth:3,clip:true}), Plot.line(second, {x:"x",y:"y",stroke: sOrange,strokeWidth:2,strokeDasharray: sys.kind==="same"?"6 4":null,clip:true})); } else {const line = d3.range(-L, L +0.01,0.5).map((x) => ({x,y: sp.m* x + sp.k}));const curve = sMode ==="A line and a parabola"? d3.range(-L, L +0.01,0.05).map((x) => ({x,y: x * x + sp.p* x + sp.q})): d3.range(0,361,2).map((d) => ({x: sp.h+ sp.r*Math.cos((d *Math.PI) /180),y: sp.j+ sp.r*Math.sin((d *Math.PI) /180)})); marks.push(Plot.line(curve, {x:"x",y:"y",stroke: sOrange,strokeWidth:2.5,clip:true}), Plot.line(line, {x:"x",y:"y",stroke: sBlue,strokeWidth:2.5,clip:true})); } marks.push( Plot.dot(sys.points, {x:"x",y:"y",r:6,fill:"currentColor",clip:true}), Plot.text(sys.points, {x:"x",y:"y",text: (d) =>"("+sFmt(d.x,2) +", "+sFmt(d.y,2) +")",dy:-14,fontSize:12,fontWeight:"bold",clip:true}) );const size =Math.min(440, width);return Plot.plot({ariaLabel:"Graph of the two equations in the system: "+ sMode.toLowerCase(),ariaDescription: sys.points.length===0?"The graphs do not cross.":"They cross at "+ sys.points.map((d) =>"("+sFmt(d.x,2) +", "+sFmt(d.y,2) +")").join(" and ") +".",width: size,height: size,grid:true,x: {domain: [-L, L],label:"x"},y: {domain: [-L, L],label:"y"}, marks });}
{const pts = sys.points.map((d) =>"("+sFmt(d.x) +", "+sFmt(d.y) +")");const ptText = pts.length===1?"x = "+sFmt(sys.points[0].x) +", y = "+sFmt(sys.points[0].y): pts.join(" and ");let rows;if (sMode ==="Two straight lines") { rows = [["Equation 1",sLinear(sp.a1, sp.b1, sp.c1)], ["Equation 2",sLinear(sp.a2, sp.b2, sp.c2)]]; rows.push(["Solutions", {one:"One solution: "+ ptText,parallel:"None: the lines are parallel (same gradient) but different, so they never cross",same:"Infinitely many: the two equations describe the same line (one is a multiple of the other)",notline:"One of the equations has no x or y term, so it isn't a line" }[sys.kind]]); } else {const isParabola = sMode ==="A line and a parabola";const quadratic = (isParabola ?"":sFmt(sys.A) +"x²") + (isParabola ?"x²":"") +sTerm(sys.B,"x",false) +sTerm(sys.C,"",false) +" = 0"; rows = [ ["Line",sLineY(sp.m, sp.k)], [isParabola ?"Parabola":"Circle", isParabola ?"y = x²"+sTerm(sp.p,"x",false) +sTerm(sp.q,"",false):"(x "+ (sp.h<0?"+ ":"− ") +sFmt(Math.abs(sp.h)) +")² + (y "+ (sp.j<0?"+ ":"− ") +sFmt(Math.abs(sp.j)) +")² = "+sFmt(sp.r) +"²"], ["Substituting","the line into the "+ (isParabola ?"parabola":"circle") +" gives "+ quadratic], ["Discriminant","b² − 4ac = "+sFmt(sys.D) +", which is "+ (sys.D>0?"positive": sys.D<0?"negative":"zero")], ["Solutions", sys.points.length===0?"None: the line misses the "+ (isParabola ?"parabola":"circle"): sys.points.length===1?"One: the line just touches the "+ (isParabola ?"parabola":"circle") +" at "+ pts[0]:"Two: "+ ptText] ]; }returnhtml`<dl class="explorer-readout" aria-live="polite">${rows.flatMap(([term, value]) => [html`<dt>${term}</dt>`,html`<dd>${value}</dd>`])} </dl>`;}