Decreasing evenly across a row - I usually think about this until my head hurts, and end up writing out all the stitches and all the decs.
Even then I get mistakes on long rows.

Surely it must be possible to catch it in a formula and get it right each time?

Of course that's possible. It's explained by Susan Kerin on her page Perfect Formula for even decreases (and increases).

Though it's explained well, it took me quite a while to get my head around it!

Now to put it in my own words...
If you want to dec X sts in a row with A sts:
First, determine the "pattern repeat" - that's a set of sts that starts with a decrease. Let's call it Y. It's calculated as A/X and disregard the fraction.
You want to end with just a decrease, not a whole pattern repeat, so you'll do the pattern repeat X-1 times. That will be Z.
You need to know how many stitches you'll use up doing the decreases: that will be B: Z pattern repeats plus 2 sts for the last decrease.
When you've done the decreases, you'll have A-B sts left over. These will be divided evenly over the start and end of the row.
Piece of cake, once you know how!

My shorthand

To dec X sts in a row with A sts:
Y (the pattrep) = A/X (disregard fraction)
Z (no. of pattreps) = X-1
B = Z*Y+2
Leftover sts: A-B. Divide by 2 and add those at beginning and end.

Trying it out

I needed to do 22 decs over a row of 238 stitches (and it should leave me with 216 stitches).
So: Y = 238/22 = 10
Z = X-1 = 21
B = Z*Y+2 = 21*10+2 = 212
Leftovers: A-B = 238 - 212 = 26 sts, 13 each end.

So I should end up with 13 + 21*9 (dec'd one, remember) + 1 (that last dec) + 13 = 216. Yes!