**I do consulting work in Norway.**Don't hestitate to contact me to discuss how I can assist you!

# Smooth taxes without brackets

- 16. October 2024
- #mathematics

I recently implemented a calculator for Norwegian income tax, and it was harder than I anticipated.
**The implementation required around 30 lines of code and 20 constants**.

In this article we use the term “income tax” to refer to everything the government deducts from gross income. To compute income tax, one must take into account the brackets, the national insurance contributions, the minimum standard deduction, the personal allowance, and so forth.

In this article we’ll simplify the income tax calculation to **one line of code and two constants**.

We’ll start by looking empirically at the Norwegian income tax, then we’ll study properties that a tax scheme should have. In the end we’ll construct a smooth tax function with two adjustable parameters \(H\) and \(k\):

We’ll show that this function has good properties and that for suitable values of \(H\) and \(k\) it approximates the current income tax very well. Below is a figure showing the average tax rate and the marginal tax rate induced by the function \(T(x)\) above. You’ll understand this figure better as you read the next sections.

## Introduction

### The tax function \(T(x)\)

Let \(T: \mathbb{R}_+ \to \mathbb{R}_+\) be the income tax as a function of gross income \(x\). For instance, if Alice earns a gross income of \(x=100\) units of money, then she might have to pay \(T(100) = 20\) in taxes, leaving her with a net income of \(x - T(x) = 100 - 20 = 80\).

If we have such a function \(T(x)\), then we can deduce three other interesting functions that answer specific questions:

- The net income \(x - T(x)\): “How much money do I have left after paying taxes?”
- The average tax rate \(T(x) / x\): “What percentage of my total income do I pay in taxes?”
- The marginal tax rate \(T'(x) \approx T(x+1) - T(x)\): “If I earn one more unit of money, what fraction of that unit of money goes to taxes?”

### Proportional and progressive tax

A tax scheme is called *proportional* if the tax rate is a fixed percentage.
In our notation, this would mean that \(T(x) = cx\) for some constant \(c\).

A tax scheme is called *progressive* if those who earn more pay a higher percentage in taxes.
In addition to progressive tax schemes, we can define *non-regressive* and *strictly progressive* tax schemes.

**Non-regressive**: the average tax rate \(T(x)/x\) never decreases.**Progessive**: the average tax rate \(T(x)/x\) never decreases, and it*increases at least once*in the domain.**Strictly progressive**: the average tax rate \(T(x)/x\) always increases.

Mathematically, these requirements correspond to conditions on the derivatives of the average tax rate. For instance, a non-regressive tax function \(T(x)\) has the constraint that

The second inequality comes from applying the product rule of differentiation. Having established some notation and concepts that we’ll use later, we will now empirically examine the Norwegian income tax.

## The Norwegian income tax

The Norwegian income tax has several deductions, a few if-then-else rules and a (mostly) increasing marginal tax rate. Once all the rules are implemented and combined, the result can be visualized as a function. The implementation was tested against the calculator Skatteberegning 2024, and in the background the income distribution from 2022 is shown.

The jumps on the marginal tax rate \(T'(x)\) make the figure a little disorderly, but notice that:

- It’s progressive, since the average tax rate \(T(x)/x\) never decreases and it does increase.
- It’s not strictly progressive because \(T(x)/x\) has two flat regions.
- The limit evaluates to \(\lim_{x \to \infty} T(x) / x = 0.474\).
- The marginal tax rate is discontinuous, and actually jumps down once.

The government often changes the effective tax rates: they adjust deductions, the lower and upper limits on the brackets and rates within each bracket.

To get an idea of how erratic these changes are, consider the highest bracket that extends to infinity. In 2020 the lower limit of the highest bracket was 999 550, then in 2021 it was raised to 1 021 550. It doubled to 2 000 000 in 2022, was reduced by half a million to 1 500 000 in 2023 and cut further to 1 350 001 in 2024.

## Properties that smooth taxes should have

To implement the Norwegian income tax I had to read up on tax rules from several sources online.
I also had to test the implementation against an online calculator multiple times before I got it right.
**Wouldn’t it be nice if \(T(x)\) was just a simple formula?**
No jumps and kinks—just a smooth, simple function.

For instance, given a constant \(k >0\), what if \(T(x) = x(1 - e^{-xk})\)? That way the average tax rate becomes \(T(x)/x = 1 - e^{-xk}\), which seems reasonable… right?

It turns out that this is a seriously bad idea, as we can see in this figure:

The net income \(x - T(x) = x - x(1 - e^{-xk})\) is maximized at \(x^{\star} = 1/k\).
There is no incentive to earn more money than this, since you *lose money by earning more*.
This is a terrible property for a tax system to have—back to the drawing board!

### Property 1: Good incentives

Let’s set a simple rule: earning more should always mean keeping more after taxes. In other words, if we increase our gross income from \(x\) to \(x + \epsilon\), then we should end up with more net income after paying taxes:

Rearranging this expression we find that the condition is equivalent to

and in the limit \(\epsilon \to 0\) the requirement says that the marginal tax rate \(T'(x)\) must obey \(T'(x) < 1\). If this inequality is satisfied, then higher pre-tax income always leads to higher post-tax income. In other words, there’s always an incentive to increase one’s gross income \(x\).

### Property 2: Progressive taxation

Another natural constraint to impose is that \(T'(x)\) should be non-decreasing, since then the tax scheme must be non-regressive. To see why this is true, note that if \(T'(x)\) is non-decreasing and non-negative, then \(T(x) = \int_0^{x} T'(\tau) \, d \tau \leq x T'(x)\). Rearranging this inequality gives \(T'(x) \geq T(x)/ x\), which is an inequality that we have seen before in Equation \eqref{progressive} in the introduction. It is exactly what is needed for a tax scheme to be non-regressive.

Note that the converse is not true: a tax scheme can be non-regressive even if \(T'(x)\) decreases.
For instance, the Norwegian marginal tax does decrease at one point, but the tax is still non-regressive overall.
If \(T'(x)\) is not only non-decreasing, but also *increases* at some point, then the resulting tax scheme is guaranteed to be progressive.

Due to these constraints on the marginal tax rate \(T'(x)\), it’s easier to find good functions \(T(x)\) if we start with \(T'(x)\) and integrate to obtain \(T(x) = \int_0^{x} T'(\tau) \, d \tau\).

## Constructing tax functions

Recall that the marginal tax rate \(T'(x)\) says how much we’ll be taxed on the next unit of money earned. For instance, \(T'(x=100 \, 000) = 0.25\) in the Norwegian income tax, so if we earn \(100\, 000\) NOK the next unit of money will be taxed by \(0.25\).

**Proposing a function.**
Let’s again consider the function \(1 - e^{-xk}\), but this time as the marginal tax rate \(T'(x)\) instead of as an average tax rate:

This function satisfies both our properties: it’s always less than one, and it never decreases. If we integrate it we obtain

Notice that our proposed marginal tax rate \(1 - e^{-xk}\) is zero when \(x=0\) and approaches one as \(x\to \infty\). The interpretation is that there is no tax initially as one starts to earn income, but if one approaches infinite income then units of money earned toward infinity will be taxed more and more.

Generalizing ever so slightly, we can change the marginal tax rate to \(T'(x) = H - (H-L)e^{-k x}\). This way the marginal tax starts at a low value \(L\) and converges to a high value \(H\). Integrating, we obtain the tax function

The current policy today in Norway is that the first units of money earned are not taxed. Therefore, let us set \(L=0\) and optimize for \(H\) and \(k\) by curve fitting to the Norwegian tax rate:

The smooth model based on \(T(x)\) is shown in dashed lines. The error is never more than 5300 NOK, so this approximation is pretty good. It’s easy to implement if you want to play around with it in Excel or Python:

```
import numpy as np
def T(x):
"""Norwegian income tax for 2024.
Max error < 5300 NOK, mean absolute error ~1400."""
H, k = 0.4772, 2.8745e-06
return H * (np.exp(-k * x) + k * x - 1) / k
```

## Summary

Income tax computation is quite complex. To implement it one needs around 30 lines of code with deductions, rules and tax brackets, all defined using around 20 constants.

In this post we examined smooth tax functions \(T(x)\). One such function is

which mimics the overall behavoir of the current income tax calculation with good accuracy.

Maybe it could be an alternative to today’s system? After all, a single formula is easy to implement compared to the current rule set with various deductions, constants and tax brackets. Everyone has access to the exponential function on their phones or computers. A simple function makes it harder for politicians to obfuscate the tax system by introducing new rules and conditions. They could still modify the tax rate by modifying constants such as \(H\) and \(k\).

One argument against a smooth function is that the average person does not understand the mathematics of it. This might be true, but then again: the average person probably does not understand what a bracketed marginal tax system is either.

### Keep it simple!

If I was a benevolent dictator, I would:

- Simplify tax formulas and other computations performed by the government as much as possible
- Favor simple, smooth functions (2-3 parameters) over discretizations and bracketing
- Require government agencies that use formulas to publish them in math and code, with tests
- Ensure that properties such as good incentives are baked into the models
- Run an exhaustive test suite to guarantee good incentives across all combinations of gross income and all manner of government payouts, ensuring that citizens are never punished for earning more and working more (this does happen, and it might be a sign of overly complex systems that have not been thought through carefully)

## Notes and references

- Continuous tax brackets were discussed on the Personal Finance & Money Stack Exchange back in 2020.
- The paper Smooth Income Tax Schedules: Derivation and Consequences by Schwarz et al discusses how various countries approach taxation and propose using smooth functions.
- A Quora post with the fantastic title The US Federal Tax Code is More Complicated Than Calculus. So Let’s Use Calculus also looks at smooth functions. The author proposes shifting and scaling a function of the form \(T'(x) = 1 - 1/(x + 1)\), whereas we shifted and scaled \(T'(x) = 1 - e^{-x}\).
- Any sensible cumulative probability density function can be used to construct \(T'(x)\), offering a flexible approach to designing smooth tax functions. I chose the exponential function because it’s relatively simple to work with.