mathronic

Essentials · Functions

Functions

A fifteen-minute read: what it is for, where it is used

23 July 1983. A new passenger jet with 69 people on board was flying across Canada from Montreal to Edmonton, after a short stop in Ottawa. About halfway there, at a height of roughly 12 kilometres, a warning lit up in the cockpit. Within a few minutes one engine stopped, and then the other. The tanks were empty.

Yet the fuel had been measured before take-off. In Montreal the aircraft's fuel gauges were not working and their displays were blank, so the ground technicians and the crew measured the fuel in the tanks by hand and concluded that there was enough for the trip. In Ottawa the measurement was repeated, and the answer was again "enough".

The text below answers this question. When you have read it, come back to your guess: what held up, and what changed?

Most of the things we want to know cannot be seen directly: how much the fuel in an aircraft's tanks weighs, or when your phone's battery will run out. But we usually have something else that we do know. In Montreal, the ground technicians went underneath each tank, pulled a measuring stick marked in centimetres down out of it, and read off how high the fuel came inside the tank.

If there is a consistent rule linking what we know to what we want to know, we can get from the known to the unknown. The technicians and the crew used two rules. First, a table took them from centimetres on the stick to litres in the tank. Next they had to get from litres to kilograms, because this aircraft worked out its fuel in kilograms: a litre of fuel weighs about 0.8 kilograms, so the litres are multiplied by 0.8. The team multiplied by 1.77 instead. That is a correct conversion factor, but one that goes from litres to pounds: a litre of fuel weighs about 1.77 pounds, and the airline's other aircraft worked out their fuel in pounds. Because a pound is less than half a kilogram, the same fuel written in pounds gives a number more than twice as large as when it is written in kilograms. The team took the pounds to be kilograms, so the tanks held less than half the fuel they believed.

In Ottawa the calculation was again done with a factor that gives pounds. Taking the fuel burned on the way off Montreal's figure gave the expected number; because the two calculations agreed, nobody grew suspicious. The official inquiry wrote that the accident had no single cause: several mistakes had piled up. The aircraft glided down onto the runway of a former military base, and nobody died.

In mathematics, a rule like this is called a function. The whole topic fits into one sentence:

A function is a consistent rule that takes you from what you know to what you do not know.

The word "consistent" is not decoration. Feed the rule the same thing and you get the same single answer every time. A table that turned the same reading on the stick into a different number every day would be useless. What you feed into the rule is called the input, and the answer you get back is called the output. The rules on the aircraft were consistent too; what misled the crew was that a correct rule was used for the wrong job. Checking whether a rule fits the job is up to whoever uses it. And there is not a working rule for every unknown: nobody has found a rule that correctly tells tomorrow's price of a share from today's, and that is what makes the stock market hard.

In short, we write this as f(x): x is the input, f is the name of the rule, and f(x) is the output. Careful: f(x) does not mean "f times x". It is read "f of x", and it means "feed x into the rule f".

Where it is used

Video through the walls · today, in every home

Between your home internet box (the modem or router) and your phone there are walls, doors and furniture. A Wi-Fi signal is a radio wave: it hits obstacles and bounces off them, so it reaches your phone along many paths, as copies slightly delayed relative to one another. The copies pile on top of one another, like sound in a room with an echo. Even so, a video in the next room plays without stuttering.

With the signal getting this jumbled on the way, how does the phone pick out the actual message?

Wi-Fi sends data in small pieces called packets. At the start of every packet there is a fixed stretch of signal that the phone already knows by heart, called the training sequence. The phone knows what was sent, and it measures what actually arrived. By comparing the two, it works out how the path is distorting the signal at that moment, that is, the rule of the path. This is called channel estimation; the "channel" is the path the signal travels along.

Then, for the rest of the packet, the data it does not know, the phone uses this rule to undo the distortion. First it goes from the known sequence to the unknown path, then from the now known path to the unknown data.

Known: the training sequence at the start of the packet · Found: the rule of the path at that moment, and then the data itself · Where the rule breaks: if noise (random interference mixed into the signal) dominates on the way, the rule worked out from the training sequence is wrong too, and the data gets corrected the wrong way.

Measuring oxygen without a needle · 1974 → today

In 2020, during the COVID pandemic, doctors noticed something strange: in some patients the oxygen in the blood was falling to dangerous levels, yet the patients did not feel short of breath. This came to be called "silent hypoxia". The standard way to measure blood oxygen is to take blood from an artery, which is not something you can do every hour.

How can you see the oxygen inside the blood without touching a blood vessel?

The small clip you put on your finger, the pulse oximeter, does it with light. Oxygen-rich blood and oxygen-poor blood absorb two kinds of light in different proportions: oxygen-poor blood absorbs more red light, and oxygen-rich blood absorbs more infrared light, which the eye cannot see. The device shines these two lights in from one side of the finger and measures how much of each gets through to the other side. What it knows is how strongly each of the two lights is absorbed; what it does not know is the percentage of oxygen in the blood.

The rule in between does not come from a formula but from measurement: volunteers had their blood sampled and the light measured at the same time, and the two sets of numbers were linked by a curve. The idea came from the Japanese engineer Takuo Aoyagi in 1974.

Known: how strongly the two lights are absorbed · Found: the percentage of oxygen in the blood · Where the rule breaks: when the rule was built, few of the volunteers had dark skin. In a study published in 2020, the device showed a normal value for some patients whose blood oxygen was actually low. This happened about three times as often in Black patients as in White patients. A rule is less trustworthy on people unlike those it was built on.

How does your phone know where it is? · today, in every phone

The map on your phone knows where you are to within a few metres, yet the phone only listens to signals from satellites about 20,000 km overhead.

How can it find where it is just by listening?

The answer lies in time. Every GPS satellite carries a very precise clock and keeps broadcasting: "This is where I am, and this is the time right now." The phone knows when the signal set off and measures when it arrived; multiplying the travel time by the speed of light gives its distance from that satellite. There are three unknown numbers: the phone's position in three dimensions. Each satellite gives one distance, that is, one measurement; if the phone's clock were perfect, three satellites would be enough for three unknowns. Because the phone's clock is cheap, its error is a fourth unknown, and a fourth satellite settles it.

Known: when the signal left and when it arrived · Found: the distances to the satellites, and from them the position · Where the rule breaks: even the smallest clock error shifts the position, because light travels 300 metres in a millionth of a second. According to Einstein's theory of relativity, a clock higher up, where gravity is weaker, runs faster; the satellite's speed, on the other hand, slows its clock slightly. Together, the two effects make the satellite's clock gain 38 millionths of a second a day on a clock on the ground. That is why the satellite clocks are deliberately tuned to run slightly slow before launch.

What the three examples have in common is how engineers think:

An engineer does not try to measure directly what they cannot see. They feed what they can measure into a rule, and the rule tells them the rest; a good engineer also knows where the rule goes wrong.

Its limits

Before you rely on a rule, ask three questions: can it be calculated, can it actually happen, can it be trusted? The same examples show all three.

Can it be calculated? GPS has four unknowns, so it needs four satellites. In a tunnel no satellite can be heard; the rule has nothing to calculate with there, and the navigation app moves you along based on your last speed.

Can it actually happen? Among tall buildings, the satellite signal bounces off walls and arrives late; while you are walking, GPS may make you jump 200 metres in one second. Nobody walks that fast, so that position cannot be real.

Can it be trusted? The oximeter's rule goes wrong on people unlike those it was built on; the Wi-Fi rule is wrong when it is worked out from a noisy sequence. The rule on the aircraft was also correct for its own job; it misled when it was used for a different one.

In the language of formulas Now let us look at a rule that is right in your hand.

When your phone's battery is at 40%, the screen says "3 h 20 min left". The phone feeds the energy left in the battery, and how fast it is using energy at that moment, into a rule. Let us work this time out ourselves.

First, a comparison: a car with 6 litres of petrol in its tank that burns 1.8 litres an hour can keep going for 6 / 1.8 ≈ 3.33 hours.

Your phone's battery is a tank too. The rate at which a device uses energy is called its power, and it is measured in watts. The energy in a battery is measured in watt-hours: a device running at 1 watt uses 1 watt-hour in 1 hour. A phone at 40% has about 6 watt-hours left in its battery; call this E. While you are messaging, the phone's power is about 1.8 watts; call this P. A phone running at 1.8 watts uses 1.8 watt-hours in an hour, which plays the part of the car's hourly fuel use. The time left, t, is found just as it was for the tank:

t = E / P = 6 / 1.8 ≈ 3.33 hours

0.33 hours is about 20 minutes (0.33 · 60 ≈ 20), so 3.33 hours is the "3 h 20 min" on the screen.

A mathematician reads this as follows: with the remaining energy fixed, the time is a function of the power.

t = f(P) = 6 / P

The input is the power, the output is the time, and the rule is "divide 6 by the power". Open a game and the power rises to about 5 watts: f(5) = 6 / 5 = 1.2 hours, that is, 1 h 12 min. The rule did not change; the input changed, and the output changed along with it. That is why the time on the screen suddenly drops.

The formula also shows where it stops working: if P were zero, the division could not be done. Asking a phone that uses no energy at all "when will your battery run out?" has no answer.

The time on the screen is not an exact answer either; it is an estimate. The rule assumes that you will go on using the phone in the same way.

The numbers are examples; real battery energy and power vary from phone to phone.

In your own words

What is a function for? Write it in your own words, with an example from your own life.

If you want to go deeper

The long version of this topic (the book) covers the same idea in detail over nine chapters and a closing word: each chapter starts with an everyday situation, first asks for your guess, and then lets you try things yourself with small experiments. It is where you will find the long explanation of the topics you will meet in your course. Each chapter opens once you have written your guess in the one before. The chapters are in Turkish for now.

Sources: Wi-Fi channel estimation: Keysight (manufacturer's document). Pulse oximeters and skin colour: Sjoding et al., NEJM, December 2020 · FDA draft guidance, 2025. GPS and relativity: GPS World. The aircraft at Gimli: the Government of Canada's inquiry report (Lockwood, 1985), FAA copy · Department of National Defence (Canada).