How is federal income taxed on a specific pay stub with a variable income?

Hello. This isn’t necessarily a question about brackets as I understand how they work. This is a question about how those brackets are applied throughout the year. I am trying to refine my spreadsheet to filter all my imported pay stubs and automate the federal income tax cell. I think I’m getting confused about what income data they are basing my bracket on: is it just an estimation based on my current paycheck, an estimation based on all my paychecks this year, etc.?

So I am in the 22% bracket covering only about $6000 of my paycheck. I am not interested in how much my year end taxes paid will be, but rather what my taxes on a specific paystub will be. Here’s the formula I’ve been using and it’s always a few dollars off:

Fed Income Tax per Pay = $179.38 + 22%*(Gross-reimbursements-deductions-FICA-State income-$1558.69)

Where I got those #:

$179.38 = (Total taxes paid 10-12% / 26) = $4807.50 26

22% = Current bracket

$1558.69 = Bracket floor / 26 = $41776 / 26