Sunday, October 8, 2023

TI-84 Plus CE: Using Matrices for "Tax Table" Calculations

TI-84 Plus CE:   Using Matrices for "Tax Table" Calculations


How The Matrix is Set Up


Each row represents a tier or a bracket.  


First column:  Lower Limit.  This is the test variable.  The first tier often will have the lower tier of 0.


Second and subsequent columns:    Variables that are associated with that tier.


Let's demonstrate this with an example.




Example Tax Bracket






This matrix has four brackets (four rows).  The algorithm starts with the last (bottom) row and tests whether the input is greater or equal to the test variable.  


According to the table, the tax rate changes at income level at $30,000, $90,000, and $270,000, with the top tax rate of 9% effective for all income excess of $270,000.


If the income is $29,999.99, the first tier of 3% is used.  If the income goes to $30,000.00, the next tier is activated.


The program ITAX, which uses this type of setup, goes "backwards".  It tests from the highest tier down.  


For example:  Income = $50,000


Start at tier 4 (bottom row). 

Is 50,000 > 270,000?  No, go to tier 3. (move one row up)

Is 50,000 > 90,000?  No, go to tier 2.  (move one row up) 

Is 50,000 > 30,000?  Yes, use the variables from tier 2.


Tax:  (50,000 - 30,000) × 5% + 900 = 20,000 × 5% + 900 = 1,900


Matrix wise:   (income - M[2,1]) * M[2,2] ÷ 100 + M[2,3]



Programs



There are two programs that illustrate this method:  


ITAX:  Income Tax Bracket.  Bracket is stored in Matrix [ A ] and has three columns:


Column 1:  lower limit of each bracket

Column 2:  tax rate for that bracket

Column 3:  additional "minimum" tax.   



BAROMET:  Calculates the air pressure and density based on height.  Scientific information is stored in Matrix [ J ].  


Column 1:  height in meters

Column 2:  mass density in kg/m^3

Column 3:  standard temperature in K

Column 4:  static pressure in Pa


If you are working in US Units, the height is converted to meters first.  After the calculation, the results are converted back into US units. 



You can download both programs here (zip file):  

https://drive.google.com/file/d/1ZCtMcJgZDLUGnrAHE6cPAkWBQQj1aHKc/view?usp=sharing



Source


"Barometric formula."  Wikipedia.  Last edited July 13, 2023.  Retrieved July 16, 2023.   https://en.wikipedia.org/wiki/Barometric_formula



Eddie



All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Spotlight: Akron Brass FireCalc Pocket Computer

Spotlight: Akron Brass FireCalc Pocket Computer Welcome to a special Monday Edition of Eddie’s Math and Calculator blog. Thi...