
Thirty-three minutes on charging one car overnight: why the cheapest hours stop being simple the moment two things want the same hour, how the plans pass the atoms in the universe before midnight, and what an unfinished game in 1654 and a paper from 1960 teach about finding an answer without trying them all. A conversation with Lily. I built the planner in my house myself. It is called Energyplan, it belongs to my company, Sourceful, and what is inside it stays inside; everything we explain comes from the textbooks. Both voices are generated, mine included, and the script was written with Claude Opus 5.5.
It’s five o’clock on a Sunday evening in November, and already dark. My car, a Tesla, is plugged in at my house, and by eight tomorrow morning it needs about ten more kilowatt-hours.
Lily’s answer is the obvious one: tomorrow’s prices are out, so charge in the cheapest hours. I thought so too. Sorting tonight’s prices from cheap to dear would take a computer well under a thousandth of a second. The little computer that plans my house, about the size of a deck of cards, took a second and a half, thousands of times longer. It was looking for one plan, among more ways to run one car and one home battery tonight than there are atoms in the universe. And it still found a good one.
So the question for this part and the next: what does it mean to make the best decision about something that hasn’t happened yet? One car and one night is about as small as that question gets.
You should know where I stand. I built the planner myself. It’s called Energyplan, I have spent a great deal of my time on it, and it belongs to my company, Sourceful. What’s inside it stays inside. Everything we explain comes from the textbooks, and some of it is three hundred and seventy years old.
For now we pretend we know tomorrow exactly: every price, every cloud, everything the house will use. Even then, it’s hard. Next time, we stop pretending.
The cheapest hours
A plan is a timetable. For every quarter of an hour until tomorrow night, it says how hard the car charges and what the home battery does. Think of a tap and a bucket: kilowatts are how far the tap is open, kilowatt-hours how much water has run in. The car needs about ten kilowatt-hours by eight, and the fuse in the house limits the tap.
Tonight’s cheapest quarters cost 2.36, 2.42, 2.44 and 2.45 kronor per kilowatt-hour, and the dearer ones go up close to four. Wide open, my charger runs at about ten kilowatts, so one quarter puts about two and a half kilowatt-hours in the bucket, and the four cheapest quarters do the job. That is very close to what the planner picked, and the car charged in those quarters that night, within a few minutes.
Lily can prove that the rule is right, and not just lucky. Take any plan that charges at almost four kronor while the quarter at 2.36 still has room. Move one kilowatt-hour from the dear quarter to the cheap one. The car gets as much, and the bill goes down, so that plan can’t be the cheapest. Start from any plan you like: the only one you can’t improve that way is the one that fills the cheapest quarters first. You sort the prices, and you’re done.
It needs no numbers, and it holds for any night and any prices, even when the cheap quarters are scattered. A kilowatt-hour at midnight fills the bucket as well as one at five.
When two things want the same hour
My house isn’t just a car. Out in the carport, in the technical room, there’s a second battery, for the house. It wants to fill up in the cheapest quarters too, and pour that energy out tomorrow at six, when power is dear.
In those quarters the car wants about ten kilowatts, the home battery five, and the house itself about one. That’s sixteen, through a fuse that allows just under fourteen. Keep that up for long enough and the house goes dark, and somebody walks out to the fuse box in their socks. So the planner never plans past the fuse. At a quarter past two that night, the car, the battery and the house used it to the last watt.
Now the proof is in trouble. Move a kilowatt-hour of the car’s charge into a cheap quarter, and the quarter is already full. To make room you push the home battery out, and it can’t go just anywhere. What it buys tonight at 2.42 kronor, it gives back tomorrow evening at about 4.60. Push it into another hour and you change what it gives back, and with it tomorrow’s bill. Moving one thing moves something else. With one car, every quarter stands alone, and a sort is enough. Add one more thing that wants the same hour, and the quarters are tied together, tonight to tomorrow evening and both to the fuse. You have to plan them all at once.
Lily tried a fair rule: the car first, and the battery gets what’s left under the fuse. But should the battery buy its last few kilowatt-hours tonight, or tomorrow at noon, or not at all? The rule never looks at tomorrow. It picks an order, and the order was the question. Her proof wasn’t wrong. The simple rule is right until two things want the same hour.
And the charger has steps: off, or at least four kilowatts, then up in small steps. The proof moved energy a little at a time, and the charger moves in lumps. So how many plans are there?
More ways than atoms
In the thirteenth century a scholar in Cairo was writing a great book of lives, and when he reached the life of a chess master, he told the old story of the chessboard. The inventor of chess asks a king for one grain of wheat on the first square, two on the second, doubling to the sixty-fourth, and the king is almost offended at how little that is. The scholar doubted the sum could be that big, until an accountant from Alexandria sat down with him and a sheet of paper and doubled it, square by square. By square sixteen it was a pint of wheat. By square sixty-four it was 16,384 cities’ worth, more cities than the world has.
My charger has eleven settings, off and ten steps. One quarter of an hour: eleven ways. Two: 121. Three: 1,331. One hour: 14,641. For the second hour my stomach said thirty thousand, my head a few million. It’s about two hundred million. The next hour doesn’t add fourteen thousand. It multiplies by it.
So try them all? Count the car’s plans as far as tomorrow’s prices reach, tonight 125 quarters, about a day and a quarter, and check a billion plans a second. Write down a one with 103 zeros after it. You would wait more than that many times the age of the universe. A computer a thousand times faster takes three zeros off.
So, I said, more ways to charge one car tonight than there are atoms. Then Lily caught us both. The car has to be full at eight, so why count to tomorrow night? Five to eight is sixty quarters, and the car alone makes a number sixty-three digits long, short of the atoms, which astronomers put at about a one with eighty zeros. She checks big numbers on purpose, her own included: once a number gets big enough, people stop checking it, and that is when it goes wrong.
What I left out was the home battery. It isn’t steps but a dial, at any power up to five kilowatts. Give it just a hundred settings, and every quarter has eleven hundred ways. The plans pass the atoms before midnight, after about twenty-seven quarters, a bit under seven hours. A real dial has no end of settings, since between any two there is another, so the true number has no end either.
Nobody tries them all, not my little computer and not the biggest computer on earth. Yet my box came back with a plan in a second and a half. How does anybody find the cheapest one?
The unfinished game
Paris, 1654. A pot holds sixty-four gold coins, thirty-two from each of two players. They toss a coin, the first to win three rounds takes the pot, and the game stops at two rounds to one. A man of fashion brought the question to a young mathematician, Blaise Pascal, who wrote about it to a lawyer in Toulouse who did mathematics on the side, Pierre de Fermat. In one letter Pascal says he is writing while still in bed, because he can’t wait.
How do you split the po…
This is a public episode. If you would like to discuss this with other subscribers or get access to bonus episodes, visit frahlg.substack.com
Fler avsnitt från "Coordinated with Fredrik"



Missa inte ett avsnitt av “Coordinated with Fredrik” och prenumerera på det i GetPodcast-appen.








