I don’t know if there’s a better term for this, since I made the term and the type of problem up on the spot, but I find myself struggling with what appears to be third grade math and it’s rather vexing.

It’s hard to explain, so I made up a word problem to illustrate it better:

A pool filled with g[sub]0[/sub] gallons of water naturally loses water due to evaporation at a rate of 1 gallon/week. To offset this, every other saturday the groundskeeper fills the pool with two gallons of water. If today the pool has been filled, what is the amount of water in the pool **w** weeks from now?

The obvious solution to this is that you have an “empty rate” of 1 gal/wk and a “fill rate” of 2 gal/2 wk, so

g(w) = g[sub]0[/sub] - 1 gal/wk * w + 2 gal/2 wk * w = g[sub]0[/sub] - 1 gal/wk * w + 1 gal/wk * w = g[sub]0[/sub]

So what’s the amount of water after 1 week? g(1wk)= g[sub]0[/sub]. Which is… clearly wrong, it’s g(1wk) = g[sub]0[/sub]-1gal (since it’s only filled fortnightly).

For this specific case you can actually find a nice-ish solution:

g(w) = g[sub]0[/sub] - 1 gal/wk * w + 2gal/wk * ( (w+1) mod 2) * w // Note, depending on how units work with modular arithmetic, coefficient is gal/wk[sup]2[/sup] – I still don’t think the units make much sense in that case

Unfortunately, it seems… hacky. I really don’t like the fact that the units of the of the last term is in gallons per a week, 2 gal/wk really makes no intuitive sense. It’s also incredibly specific to a problem of precisely this form, anything that’s not on a precise interval (i.e. “once every n weeks the pool is filled n gallons”) doesn’t work. It also, to my knowledge, doesn’t really take into account “half-steps”, such as how many gallons would be in the pool after a week and a half – though I’ll admit I’m not clear on the particulars of continuous modular arithmetic.

Is there an more elegant way to state a solution to a problem of this type? The only other method I can think of (for the general case) just involves a piecewise function, but I don’t like piecewise functions unless they’re absolutely necessary – they’re kind of messy. But I can’t deny that the graph looks a LOT like a piecewise function, so maybe that’s where this type of problem is doomed to go.

Note that the word problem is a really simple case. A more complex case might be that for three days every week, the pool has a pump on that fills the pool at a rate of x gallons per day, or in the extreme case that it’s filled by one gallon two random days (with 100% certainty) in a recurring n-day period. It also need not be periodic like this one, maybe you have a net loss or gain of whatever you’re measuring. So don’t get too myopic on the really simple problem I presented, I’m talking about strategies for solving such a problem generally.

I don’t need this for school, research, work, or anything. The idea just came to my head and now it’s bugging me.