A taxing algorithm

My first encounter with the term algorithm did not come from Don Knuth. I learned it from the Internal Revenue Service. Sometime in the late 1960s or early 70s the IRS introduced a redesigned Form 1040 based on a principle borrowed from the world of computing: the algorithm. What this meant, I soon discovered, was that the wording of the instructions would be procedural rather than declarative. Instead of “Your tax is 15 percent of the amount on line 42,” we had “Multiply the amount on line 42 by 0.15 and write the result on line 43.” I had expected something more revolutionary, but at least I expanded my vocabulary.

I’ve filled out a lot of 1040s since then, but until yesterday I had never become acquainted with Schedule D (Capital Gains and Losses). What a treat I had waiting for me! Tucked inside the Schedule D instruction book, I found a marvel of labyrinthine arithmetic and logic. The tax worksheet on pages D-15 and D-16 might well be the most complex algorithm that ordinary people are ever asked to perform.

Below is my attempt to represent the worksheet as a data-flow diagram. Inputs (mostly dollar amounts copied from elsewhere in the tax return) are in blue; the eventual output (tax owed) is in red; the flow is mostly from bottom to top. The numbers in the boxes correspond to line numbers in the worksheet.

The directed graph has 82 nodes and 96 edges. Twelve subtractions, seven additions, four multiplications, ten comparisons, and two table lookups. Now that’s an algorithm! It’s gnarlier than calculating the date of Easter.

What are the chances that I correctly followed all the steps of this algorithm? What are the chances that the published algorithm correctly implements the intent of the tax code?

As the legend at the bottom of the chart indicates, that function is \(\min(a, b)\) and either \(a\) or \(b\) ends up in the output.

But I don’t dispute the likelihood of mistakes. My point in making the chart was to suggest that the IRS might consider some of the later lessons of computer science, having to do with concepts such as modularity and abstraction.

You are likely misreading the diagram, I misread it at first too. The numbers in the boxes are where data is coming from or going to. So for the top left part where you get [45] = min([44], [43]) , you find the minimum of lines 43 and 44, and put that result on line 45.

I made two failed attempts with pencil and paper, then produced the drawing you see with Adobe Illustrator. In this day and age it’s a little embarrassing to admit that I do such things by hand, but then I also still file my taxes by carrying a fat envelope to the post office.

without a doubt the tax system is one of the most messed up/ labyrinthine bureaucracies on the planet and shows similarities to decades-old legacy code in IT. you didnt even get into how corps are not taxed effectively, that loopholes worth millions or even billions of dollars exist for corps or wealthly individuals, the irrationality of various (non)taxes etc…. changes over the last few decades decreasing max rates probably contributes massively to wealth inequality…. etc! and years ago prez reagan talked about “tax simplification”…. aieeee!