That's how you posed the question. This is the kind of question calculus addresses. I'm done with calculus. Retirement is good.
You can run the calculation though with good ol’ algebra.
1. Assume 40gal barrel, use 20gal a year and top up once per year.
2. Use 50% a year (20/40)=0.5
Year 1: 40 x 0.5 = 20 gal of original left
Year 2: 40 x 0.5 x 0.5 = 10g gal of original left
Run this as far as you want to go, it will never equal zero.
Calculus is tool to derive an equation. The derived equation is used for the calculation itself. In this example, you can eyeball the equation as Gal original left = 40gal x 0.5 to the power of the year number. This is just a button push on a scientific calculater.
As far as the stabilizer goes, read the manufacturer's instructions for usage. As far as common sense, if the manufacturer says something like a 1-year shelf life for the stabilized fuel, don't exceed that.
Keep the storage barrel or tank topped up and vented but assure a 100% turnover a few times a year. If you know a rancher or farmer, they will have the best practical advise. They always have onsite fuel storage for trucks and tractors in a volume making an off the shelf stabilizer uneconomic to use.
If storing fuel for emergency or shtf supply, avoid any partial use as much as possible and keep the tank sealed properly. Add stabilizer. Read manufacturer instructions. Call the manufacturers directly and talk to their technical service experts with your exact details and plans. Customer service is normally not competent for this kind of assistance - Ask specifically for technical service for application assistance. If you have a backup generator for example, the system manufacturer should have exact instructions for fuel storage. If a person wings it and fouls up the fuel system, that's likely an out of warranty issue at the owners cost and could completely invalidate the warranty. Your decisions.
Diesel and gasoline have different storage considerations. Both will have water issues but diesel has additional problems with sludge and bacteria contamination.
Make sure that any tanks, barrel, pumps, hoses, valves, jerry cans, vents, etc. are UL or USCG certified for the exact fuel duty. Don't want to blow yourself up. Outdoor storage is easier than vented indoor.
I once had a diesel fueled backup generator system built within a shipping container. Industrial system. I absolutely dreaded the monthly running of that system personally if my operators were unavailable. Call the alarm and power company, start the generator, manually switch power loads, etc. Several page checklist and easy to foul up and damage something, service trucks racing to the remote site and calling corporate a 1000 miles away.
I was thinking that if the fuel was being refreshed continuously, this would be a differential equation. Darned glad I never had to do these, no tables on the inside of my copy of Thomas.
Glad there are some nerds here.