*Last Updated: November 8, 2022*

In the previous post, I discussed how to compute the taxable amount of your social security income (SSI). Which is unfortunately a bit complicated, but we got it done.

The next step is to figure out how to pay no (or minimal) taxes on that taxable amount of your social security, which is vital for the Tax and Penalty Minimization (TPM) method described in the Withdrawing Money After FIRE post.

You’re probably thinking “uh… doesn’t the definition of taxable mean you’ll pay taxes on it?”

That’s where the beautiful standard deduction comes in. As long as your taxable SSI is less than or equal to the standard deduction, you’ll pay no taxes on it. Similarly if your taxable SS remains within the lowest tax bracket, you can ensure you won’t pay more than the lowest tax rate.

But how do you ensure the taxable SSI stays within these limits? That question is the topic of this post.

**Targeting Total Standard Income and Long Term Cap Gains**

Your total standard income includes all non-SSI standard income (including non-qualified dividends, retirement account withdrawals or rollovers, earned income, etc.) plus your taxable SSI.

And as discussed in the previous post, your taxable SSI is a function of four things:

- SSI
- non-SSI standard income
- long term capital gains and qualified dividends (which I’ll collectively refer to as LT cap gains, as they are taxed at the same rate)
- tax filing status (married filing jointly vs all other filing statuses)

So as discussed in the FIRE Withdrawal Strategy Algorithms page, what we want to do is *target *a specific amount of non-SSI standard income and LT cap gains that gives a taxable SSI that fits into these equations:

- taxable SSI + non-SSI standard income = standard deduction (or top of lowest tax bracket if you prefer, but I’ll be shooting for the standard deduction in the rest of the article)
- taxable SSI + non-SSI standard income + LT cap gains = top of 0% LT cap gains tax bracket

By doing this targeting as part of the TPM method, you can significantly reduce your tax bill, hopefully down to $0. Those lower tax bills can result in tremendous gains over many years with compounding growth.

**Targeting Algorithm**

*NOTE**: After considering the impacts of large RMDs, I updated the below algorithm on the **FIRE Withdrawal Strategy Algorithms page**. See that page for the latest version.*

The following is a high level description of the targeting algorithm that I implemented in python, to provide a general sense of how it works. For more details, please see the code itself.

### Targets

As mentioned above, we want the maximum standard income (taxable SSI + non-SSI standard income) to equal the standard deduction for your filing status (e.g., $12,950 for single filers, $19,400 for heads of households, $25,900 for married couples filing jointly), so you won’t pay income tax on any of that income.

We also want LT cap gains such that when you add those gains to the max standard income we reach the top of the 0% LT cap gains tax bracket (e.g., $41,675 for single filers, $55,800 for heads of households, $83,350 for married couples filing jointly), so you won’t pay any LT cap gains taxes.

Finally, adjust the maximum standard income you’re shooting for by subtracting any nonqualified dividends and other sources of income you can’t easily dial up and down (e.g. a pension). We’ll call this “remaining standing income room”.

### Solve for Max Non-SSI Standard Income

Now that we have our targets, next we need to solve for the max non-SSI standard income. This value, when added to taxable SSI, should equal the above “remaining standing income room”.

The challenge we immediately encounter is that it doesn’t appear possible/practical to manipulate the equations to directly solve for the appropriate max non-SSI standard income (let me know in the comments if I’m wrong). Why? Because taxable SSI is also a function of the non-SSI standard income, and thus any changes to non-SSI standard income also affect the taxable SSI (nominally).

So how do we deal with this stickiness? When I see a situation like this, I typically reach for a numerical solver, which can use well-established numerical optimization methods to converge on the desired solution. In fact, even if I believe it might be possible to eventually suss out a direct analytical solution, I will often save the time and effort and just employ a numerical solver – especially if there’s no reason to believe the underlying functions will take a lot of computation.

The numerical solver we’ll employ is the highly optimized scipy.optimize.newton routine, which employs the Secant method to solve for the appropriate max non-SSI standard income. The goal of the Secant method (or Newton’s method) is to find the point where a provided function is equal to zero. So we need to structure our function so that when we have the desired answer, the “zero function” returns zero.

So if our “remaining standing income room” = max non-SSI standard income + taxable SSI, and taxable SSI is a function (f) of max non-SSI standard income, SSI, and LT cap gains, we need to rearrange this equation to equal zero. So:

max non-SSI standard income + f(max non-SSI standard income, SSI, LT cap gains) – “remaining standing income room” = 0

That’s the zero function we’ll use with scipy.optimize.newton, to solve for the appropriate max non-SSI standard income.

One last thing the numerical method needs: a good starting point. Otherwise it might not converge on the correct result, if it’s starting in a totally wrong region. The starting point we’ll use for the max non-SSI standard income is simply the “remaining standing income room”.

After we run scipy.optimize.newton to solve for the max non-SSI standard income, we can easily directly compute the taxable SSI as the “remaining standing income room” minus the max non-SSI standard income solution.

### Solve for Max LT Cap Gains

If all goes smoothly in the previous section, your taxable SSI will be less than the “remaining standing income room”, and the balance will be the max non-SSI standard income.

In that situation, the maximum LT cap gains targeted is unchanged – when added to the total standard income, it will exactly equal the top of the 0% LT cap gains tax bracket. Easy.

BUT, what if your SSI is large enough that the taxable SSI is greater than the “remaining standing income room”? Even if non-SSI standard income is zero?

Well at that point you’ve got to reduce your LT cap gains, so that taxable SSI does not exceed “remaining standing income room”. The question then is how to compute the maximum LT cap gains you can have while keeping taxable SSI at that “remaining standing income room” value.

After verifying that it is possible to get the taxable SSI less than or equal to the “remaining standing income room” value by setting all other income to zero, we’ll employ the same Secant method via the highly optimized scipy.optimize.newton routine as above, solving for the appropriate max LT cap gains.

As in the previous section, we’ll need a reasonable initial guess at the final max LT cap gains solution for the numerical solver to start in the correct region. Unlike in the previous section, I found I needed a stronger initial solution for this part of the algorithm. So for every $1K increment of LT cap gains values from $0 to $100K, I compute the taxable SSI. The LT cap gains value that is closest to the “remaining standing income room” I select as the first guess for the numerical solver.

There is one caveat to this initial solution method though: if the taxable SSI has reached the maximum 85% of SSI, then that won’t work as an initial guess. Why? Because the function is essentially “flat” at that point: no matter how high the LT cap gain value is, the taxable SSI will remain the same. Numerical solvers work by using the gradients of the function to find a single distinct answer, so a completely flat line eliminates the ability of the solver to know which way to go to find the answer. Thus any LT cap gain value that produces the maximum 85% of SSI value is ignored for this initial guess process.

The “zero function” we’ll use with scipy.optimize.newton, to solve for the appropriate max LT cap gains, is even simpler than the previous section:

f(SSI, LT cap gains) – “remaining standing income room” = 0

where the function (f) is the taxable SSI.

Once the solver finds the appropriate max LT cap gains, and thus taxable SSI equals “remaining standing income room”, we also set the max non-SSI standard income to zero.

**Plots**

Alrighty, now that we’ve laid out the algorithm, let’s see what it produces. And build up some intuition about how the algorithm is working.

If you know your filing status and SSI value, you can look at these plots to see the maximum non-SSI standard income and LT cap gains you can have without paying taxes on any of these income sources.

### Filing Status: Single, Head of Household, Married Filing Separately, or Qualified Widow(er)

First up, let’s look at plots for the single, head of household, married filing separately, or qualified widow(er) tax filing status.

If we plot the taxable SSI, maximum non-SSI standard income, and maximum LT cap gains versus SSI for SSI values ranging from $0 to $50K, we get the following figure:

Taxable SSI (red) starts at $0 and levels off at the standard deduction value of $12950 when SSI is around $30K. The maximum non-SSI standard income (blue) does the opposite: starting at the standard deduction value of $12950, it levels off at $0 when SSI is around $30K. And during that interval from SSI = $0K to $30K, the max LT cap gain value (green) remains constant – because the total standard income (taxable SSI + non-SSI) never exceeds the standard deduction.

The maximum total taxable income (black) also remains constant, because the other three other lines alway sum up to the same value.

After $30K, the max LT cap gain value shrinks as needed to ensure the taxable SSI stays at the standard deduction value, which means the maximum total taxable income also shrinks. But your SSI is also increasing to quite sizable amounts, so you are likely to be just fine from a cash flow perspective. And this way you ensure no taxes are paid on your SSI.

There is one interesting additional bend point between $0K and $30K though: shortly before $10K SSI, the slopes of both the taxable SSI and maximum non-SSI standard income become significantly less steep. What’s the deal with that?

Turns out that is the point when Taxable SSI shifts from 85% of the SSI value (you can see the slope is pretty close to 0.85 for Taxable SSI prior to that point, and -0.85 for non-SSI) to values less than 85% as dictated by the taxable SSI algorithm. Prior to this point, the SSI value is small enough versus non-SSI and LT cap gains that the taxable SSI is 85% of SSI, but after that point, a different branch of the taxable SSI algorithm is employed (taxable SSI = taxable portion in the 50% bracket + taxable portion in the 85% bracket).

### Filing Status: Married Filing Jointly

Next up, let’s look at the same plot for the Married Filing Jointly status. Though I’ve increased the plot x axis from $50K of SSI to $100K of SSI, due to the larger maximum SSI possible for a married couple.

You can see how the taxable SSI line (red) has the same slope until it hits the “married filing jointly” standard deduction of $25900, indicating that it equals 85% of SSI until that point (around $30K SSI). And just as in the previous plot, the maximum non-SSI standard income (blue) does the opposite of the taxable SSI, leveling out at $0, and the max LT cap gain value (green) remains constant.

When the taxable SSI reaches the standard deduction level around SSI = $30K, there is a large instant jump down in the max LT cap gains. What’s the deal with that?

In general, I’m always suspicious of large instant jumps like this (very often it’s a bug in the algorithm or implementation), but in this case I believe it’s legit: because the taxable SSI did not exit the “85% of SSI” region mentioned above prior to this point, the max LT cap gains have to jump quite a ways down for the taxable SSI to depart that “85% of SSI” region. Otherwise it won’t be possible to keep the taxable SSI at the standard deduction level by lowering the max LT cap gains – it will simply remain 85% of SSI. But from that point on, a simple linear reduction in the LT cap gains is enough to keep the taxable SSI at the standard deduction value.

**Example Scenarios**

Now that we’ve waded through the algorithm and some pretty plots, let’s show how this method can save you $$$. And remember that this method is used within the TPM method, so you automatically get these benefits if you employ that method.

Also note that I’ve not accounted for taxes that might result from required minimum distributions (RMDs) that start at age 72 – future post.

### Paul and Paula: Retired and Single

Paul and Paula are single retired people that are now both receiving $20K a year in social security income (SSI).

Paul doesn’t know anything about how his SSI is taxed, and he’s not too concerned about it either. He did read somewhere that it’s a good idea to max out your standard deduction ($12950 for 2022) with retirement account withdrawals, and to sell enough shares in his brokerage account such that his cap gains (including any qualified dividends he has) plus retirement account withdrawals add up to the top of the 0% tax bracket for single filers ($41675 for 2022 – which means $28725 LT cap gains). But he doesn’t think about how his SSI is taxed at all.

As a result, $17K of Paul’s $20K SSI is taxable, and he will **owe $1834.50 in federal income taxes**.

Paula is a bit smarter and employs the targeting income approach we’ve discussed. As a result, her taxable SSI is $10553.38, she pulls $2396.62 from her retirement account (instead of $12950 like Paul), her LT cap gains (including qualified dividends) are $28725 (same as Paul), and **her federal income tax bill is $0**.

She then buys a very fancy bottle of champagne for $1834.50 to celebrate – and it’s the best champagne she’s ever had.

See the diagram at the top of the post for a graphical version of this example.

### Hanah and Harry: Retired and Married

Hanah and Harry are both married (not to each other) and retired, and each couple pulls in $40K a year in SSI.

Hanah and her partner are like Paul above: they don’t know anything about how SSI is taxed, and they believe it’s probably not that important. Again like Paul, they did hear it’s a good idea to max out their standard deduction ($25900 in 2022) with retirement account withdrawals, and to max out their 0% LT cap gains bracket ($83350 in 2022 – which means $57450 LT cap gains) by selling shares in their taxable brokerage account.

The result: $34K of their $40K SSI is taxable, and they will **pay $3669 in federal income taxes**.

Harry and his spouse are a bit smarter, like Paula above, and employ the targeting income method. Thus their taxable SSI is $25900 (equal to the standard deduction, so no funds are pulled from their retirement accounts), their LT cap gains (including qualified dividends) are $47411.76, and **their federal income tax bill is $0**.

They then fly to Paris in business class for $3669, clinking their champagne glasses to the power of MATH. (Though of course they wouldn’t actually pay this amount – they would use points!)

Here’s a pretty graphical representation of this example:

**Code**

If you’d like to plug in your expected or actual social security income, along with any other sources of income you can’t easily dial up and down (e.g. a pension), you can download the code or modify and run the embedded Python interpreter below.

You can then see the maximum amount of non-SSI standard income and maximum LT cap gains you should strive for in order to not pay any taxes. You can also view the same plots shown above for the different filing statuses, and tweak those to your liking if desired.

Modify the user inputs section at the top as desired, then hit the Run/Play (sideways triangle) button to generate the plots. To go back to the script to make any changes, hit the Pencil icon. If you want the text larger, hit the hamburger menu button, then scroll to the bottom to see larger font options. In that same menu you can also Full Screen the window, and other actions.

Note that you can use the inputs labeled as “married filing jointly” and “other filing status” to obtain the same plots as above. Use the pound sign “#” to comment out a line so that it’s not used.

**Future Work**

Everything in this post revolves around paying $0 in taxes – but if your situation doesn’t allow that for some reason it can also be advantageous to ensure you stay in the lowest or lower tax rates. It would also be neat to look at a plot of the taxable SSI, and the resulting taxes, if you don’t adjust the LT cap gains once the taxable SSI reaches the standard deduction value. And you could also just adjust the LT cap gains by the amount the taxable SSI exceeds the standard deduction, so the total remains at the top of the 0% LT cap gains bracket – you’d just start to pay taxes on the standard income because it exceeds the standard deduction (and still no LT cap gains taxes).

**Conclusions**

Much like investing, taxes can get a bit complicated at times. But unlike investing, which can be very volatile and random (in the short term) by nature, taxes are a deterministic set of rules which we can study and optimize to our heart’s content – without worrying about if we have to completely change our strategy every year.

Targeting your non-SSI standard income and LT capital gains when you have SSI is a fantastic example of this – I know that no matter what the markets are doing any particular year, this approach will likely save thousands of dollars in taxes every year.

Many (most?) people also don’t seem to realize how feasible it is to pay ZERO federal income taxes each year as a retiree. With just a little math and planning (and some fun numerical optimization tools), you can maximize your taxable income while paying no taxes – which means more money for retirement spending or continuing to grow your portfolio for eventual future charitable giving or your children’s inheritance(s).