Like a good procrastinator, I did my taxes this past weekend. I was a bit curious as to what people have done with Mathcad in the past. After all, most of the work is filling in boxes, adding and subtracting, and an occasional multiplication here and there. The only thing I found was this post in the PTC Communities page.
The Essential Mathcad for Engineering, Science, and Mathcad book by Brent Maxfield also has a similar tax example. If you have the 2nd edition (2009), it’s Engineering Example 8.2. If you have the Prime 3 edition (2014), it’s Engineering Example 9.2. But I wanted something more along the lines of what we in the U.S. go through with our tax forms. Now I will admit to using TurboTax. I have used it for about five years now. It is a bit addictive because once you use it, info can be transferred over the next time you use it, as in when you buy and install next year’s release. The interface walks you through the fields that you need to fill in, and the “calculations” (the aforementioned add, subtract, and multiply) are done for you.
Well, I know that with all these tax preparation software out there, one would probably not buy Mathcad to do their taxes. But what if they did? What would that look like? So this is where I give the disclaimer that what I am doing here is purely for personal amusement. I can not guarantee that there are no mistakes. So if you decide to build on my work for your tax returns, you have been warned.
The first step is to download Form 1040 from the IRS for the 2013 year. I then basically tried to convert each line over to Mathcad Prime. Each numbered line will be put into an array, L. We start off with one of the trickier sections – exemptions.
To convert that, I used another array to capture the exemptions, and then summed up to get L6.
Then the rest of page one is pretty straight-forward. You fill in a bunch of fields for your wage/salary, interest, dividends, and other forms of income. Here is what that looks like in my worksheet.
When you get to the end of the section, you sum up all the numbers in that section to get your total income. So L22 is actually the sum of L7 through L21.
I’ll skip through the first portion of the adjusted gross income. Line 39 is where you specify if you or your spouse is born before January 2, 1949 and/or is blind. This is done similar to the adding up of the exemptions.
Line 44 is by far the most interesting part of this worksheet. It’s the value that you get when you look up your taxable income (line 43) in a tax table. For ease of inclusion, I’ve put the table into an Excel component. Note that the tax table is dependent on your filing status. For that reason, I create a string that represents the spreadsheet range to read from the Excel component based on the filing status.
‘taxTable’ is a function that takes in a taxable income (L43) and compare is with the ‘At Least’ column until it finds the appropriate row. It then returns the value from the tax column at the same row number.
The rest of the form is more or less of the same, so I will just leave it at that. It basically computes any credits, and then compares how much taxes you have already paid with the amount that you should have paid. If you overpaid, then you get a tax refund. If not, you will need to mail in a check to the IRS!
Download the worksheet used to generate the above images.