Oh dear! I think this may be beyond me.
lol
i thought this
z = x + y - (x * 0.15) + ((12,500-y) * .2)
was less complicated than your version
z = (((x X 0.75) + y)) - 12500) X 0.2 + (x X 0.25)
Anyway i was in a bit of a rush to go to the pub yesterday so lets do a quick proof check of the formula
Ok lets use random amounts (honest gov its not a fix - try your own)
x = £24,470.59 - main pension
y = 8000 state pension
personal allowance = 14000
so z =
24470.59+8000 - (24770.59*.15) + ((14000-8000) *.2)
+24470.59+8000-3670.59 + 1200 = 30,000 - tick part 1
Proof of the pudding tax comp
24470.59 pension
6117.65 tax free
18352.94 taxable
add 8000 state pension
26352.94 taxable
14000 personal allowance
12352.94 taxed at 20% = 2470.59
net income =
24470.59 private pension + 8000 state pension - less 2470.59 tax paid = £30,000 bingo