Calculate one billing cycle's card interest using the average daily balance method, and what paying on the first day would save.
Model and assumptions. For each day of the cycle the balance is the starting balance, plus the purchase from its day on, less the payment from its day on, never below zero. The average daily balance is the mean of those daily balances. Interest is the sum of the daily balances times the APR divided by 365, which equals the average daily balance times the daily rate times the days in the cycle. The ending balance adds that interest to the starting balance and purchase, less the payment, and goes negative if you overpay. The early-payment comparison moves the whole payment to day 1. Days beyond the cycle length count as the last day, and the model ignores a grace period, which can waive the interest entirely if you pay the statement balance in full.