Nando’s put it succinctly on its Twitter feed last month: “The UK supply chain is having a bit of a mare right now.” Getting things on to supermarket shelves, through your letterbox or into a restaurant kitchen has certainly become problematic of late. It’s hard to know exactly where to pin the blame, though Covid and Brexit have surely played a part. What we *can* do is give thanks for algebra, because things would be so much worse without it.

It’s likely that you have mixed feelings about algebra. Even if you could knuckle down and manage it in school, you probably wondered why it was important to solve an equation involving x raised to the power of 2 or why you should want to find a and b when a + b = 3 and 2a – b = 12. You might even feel that your scepticism has been vindicated: the chances are that you have never done algebra in your post-school life. But that doesn’t mean that the jumble of letters, numbers and missing things that we call algebra is useless. Whether it’s supermarket groceries, a new TV or a parcel from Aunt Emily, they all reach your home through some attempt to solve an equation and find the missing number. Algebra is the maths that delivers.

Algebra has been around for millennia. The word comes from the Arabic word al-jabr in the title of a ninth-century book on calculation, but ancient peoples in Babylon, インド, China and Africa had been solving algebraic equations long before that. です, essentially, the art of finding unknown numbers, given certain others. The sought-after hidden factor was usually referred to in Latin as the cossa, or “thing”, and so algebra was often known as the “cossick art”: the art of the thing.

Early adopters of algebra didn’t have the luxury of solving equations: until the 16th century, everything was written out in words. An early student of the cossick art might find themselves face to face with something like the following: two men are leading oxen along a road and one says to the other: “Give me two oxen and I’ll have as many as you have.” Then the other said: “Now you give me two oxen and I’ll have double the number you have.” How many oxen were there and how many did each have?

This poser comes from a compendium of puzzles, published in around AD800, と呼ばれる *Problems to Sharpen the Young*. It is not that different from the questions we all faced in maths lessons at school and a prime use of algebra today is still about calculating numbers of oxen on the road – for stocking the butcher’s counter at your supermarket.

“Stocking warehouses is a complicated problem,” says Anna Moss, principal data scientist at Ocado Technology. Moss’s role involves ensuring that the amounts of stock ordered from suppliers are sufficient to satisfy customer demand, but do not exceed the warehouse storage capacity and, importantly, minimise food waste.

Moss, you might not be surprised to learn, is a maths whiz. She has worked for Intel in the past and frequently publishes her mathematics research in academic journals. Applying such expertise to grocery delivery might seem like overkill, but the logistical puzzles involved are every bit as challenging as anything she has faced elsewhere.

The maths of logistics starts with algebra – linear algebra, 正確には. This is algebra where the variables (data about warehouse stock, 例えば) tend to be processed in ways that don’t depend on the square, the cube or any other power. そう *y *= 4*NS *would be an operation in linear algebra; *y *= 4*NS ^{2}* would not.

Linear algebra explores solutions for sets of equations that together contain all you need to find out the relationships between the variables. Its equations are, essentially, mathematical spreadsheets where a single operation can process a huge array of data, expose the relationships between them all and allow the mathematician to optimise one particular chosen outcome. The same trick lies behind Google searches, flight scheduling and parcel delivery; even the way your virtual shopping basket is delivered to your computer screen involves linear algebra in the logistics of routing information through the internet.

Logistics hasn’t stood still with linear algebra, しかしながら. It has been developed into algorithms for “linear programming” and “mixed integer programming” and various other odd-sounding mathematical routines, such as “combinatorial optimisation”, “greedy heuristics” and “simulated annealing”.

“You can think of this as computational algebra,” says Keith Moore of US logistics software company Autoscheduler.AI. And it’s all done with just one purpose: to deliver to every customer, on time and in full – OTIF as it’s known in the trade. そして, as anyone working in post-Brexit supermarkets knows, that’s never actually possible. “In every distribution centre I’ve been around, the constraints keep the operation from perfectly maximising OTIF,” Moore says.

It’s Moore’s job to maximise what is possible for a wide range of clients, including Unilever and Procter & Gamble. He doesn’t use paper and pen or a calculator. “Even at a single distribution centre, they are collecting gigabytes of data every minute and that data changes constantly. It’s not just impractical to have analysts and people sitting in a room doing math to make decisions, it’s completely unfeasible.”

代わりに, the necessary algebra is programmed into software. The exact nature of the algorithm at work is, もちろん, a trade secret. That’s why numerous companies refused to speak to me for this article: they were worried their mathematicians might say too much. セインズベリーの, DPD and Hermes all declined an interview request on the basis that the mathematical tricks used to improve their service are, as DPD’s PR put it, “not something they want their competitors to know about”.

What we do know is that delivery is a terrifying algebraic challenge, with far more variables than you ever encountered in any exam question. Ocado’s optimisation algorithms, 例えば, consider how to pack ordered items in the smallest possible number of bags, as well as the best path to be travelled by a robot in a warehouse or by a personal shopper in a store picking the products from the shelves. But they also have to factor in the time slot that you selected, the capacity of the van and myriad other factors such as achieving minimal environmental impact. “All these criteria are given weights based on their relative importance and this weighted combination serves as a single value to be optimised,” Moss says. “In addition, our problem keeps changing all the time, as customers place new orders and edit the existing ones. Our algorithms have to cope with these on-the-fly changes.”

Then there are the optimal delivery routes, given the location of warehouses and stores relative to your home address. “We know the travel distances between all pairs of these locations,” Moss says. “The problem is to find the best van routes or the way to assign orders to vans and determine the sequence for each van in which to deliver its assigned orders.”

Assuming you can find drivers and fuel, the mathematics of delivering goods efficiently is actually an instance of a long-standing problem for mathematicians: the travelling salesman problem. Cut to the bone, it is this: how do you find the shortest path that allows you to visit a number of locations only once?

You don’t have to treat this as an algebra problem, strictly speaking, although linear algebra does provide one angle of attack. Others come through algebra-derived disciplines such as graph theory. しかしながら, the precise nature of the mathematics is somewhat moot, since there is no way to solve the travelling salesman problem once you are dealing with a realistic number of destinations.

While there are six options for travelling from a distribution centre to three destinations, there are 479m possible ways to deliver to just 12 destinations. A single parcel delivery driver might deliver 60 または 70 parcels a day and there are trillions of possible routes for that relatively small number of deliveries.

No one expects even a computer to work through them all, so software, such as UPS’s Orion, makes a guess at a best route, examines its issues and then improves on it. This is the approach known as heuristics. It is another high-powered relative of school algebra and tries to get as close as possible to optimal solutions. Although it starts with guesswork, it’s still validated by maths. “Mathematics gives us the confidence that we are close enough to the best option,” says Ravi Ahuja, founder and CEO of two logistics optimisation companies Optym and Axele.

Nowhere is this more important than in the airline industry. ここに, variables include what routes to fly, how many flights to operate per route and at what times and, もちろん, the best way to schedule each plane, crew member and passenger for maximum profit. “Timing is everything for airlines, as that enables inbound planes to connect with outbound planes, crews to go from one flight to another, passengers to fly when they want to and make flight connections,” Ahuja says. “For a large passenger airline that flies thousands of flights a day, it is a massive and tremendously complex mathematical problem.”

And you solve it with algebra. “We use several techniques, including greedy heuristics – take one decision at a time but the best one – or mixed integer programming, which relies on linear algebra,” Ahuja says. He is proud to say that his algebra skills once allowed him to find an optimal solution for a hideous set of equations on behalf of an airline and the company saw its profitability surge by millions of dollars a year.

So learning algebra wasn’t a waste of time – for Ahuja and the others who keep our deliveries coming in these trying times, 少なくとも. Moss never felt it was, to be fair: maths was always her favourite subject and she has built her career on “a solid math base learned in school”, as she puts it. “I consider myself lucky," 彼女が言います. “I still enjoy doing maths and have a chance to do the things that both truly interest me and make a difference to society.”

Not that these mathematicians all keep things strictly professional. “I sleep pretty well every night knowing that we’re helping companies reduce costs and run greener operations,” Moore says. “But from a personal perspective, building an algorithmic fantasy football team that absolutely destroyed the 2019 NFL season was pretty great too.”