Formula to work out tax payable

Hi, I'm trying to work on a formula that can calculate the tax payable given that we have different tax rates for different thresholds. So for example, let's say we have the following tax table.

**Taxable Income** | **Marginal Tax Rate** |

$0 - $10,000 | 10% |

$10,0001 - $20,000 | 15% |

So, if our income is $x, is there some formula I could use to calculate the tax payable. I know that this can be very easily calculated once we have $x. Although is there a formula as a function of $x that could calculate the tax payable? I was initially thinking of using matrices, although I'm not too sure how that would work. Any suggestions would be appreciated.

Thanks

Re: Formula to work out tax payable

If I am interpreting "**marginal** rate" correctly, it is very simple:

if I (income) is less than $10000, the tax is .1I or I/10.

If I is larger than or equal to $10000, the tax is $1000+ .15(I- 10000).

That "$1000" is, of course the tax on the first $10000 income, and then you apply the 15% rate to the remainder: if you earn $45000, you pay 10% of the first $10000, or $1000, plus 15% of 45000- 10000= 25000 so you pay .15(25000)= $3750 on the rest for a total tax of $4750.