The gemara (Y'vamos 82b) discusses iteratively replacing mikva water with fruit juice.1 The case involves adding one se'ah of fruit juice to a 40 se'ah mikva, and then removing one se'ah of the solution. R' Yochanan rules that this iterative process may be repeated so long as more than 50 percent (or at least 50 percent) of the solution remains water.
Rashi (s.v. mai lav) seems to comment that no more than 19 iterations may be performed.2 Tosafos Y'shanim (ad loc.) points out that 20 iterations does not mathematically get you below 50 percent (assuming some mixing of the solution occurs during this process), but concludes that 20 iterations would still render the mikva rabbinically invalid because it "appears like a majority" of the solution is fruit juice.
Rashi's wording ("d'lo nishkol ruba, aval ad palga shapir dami") does not strike me as amenable to this approach. My guess is that Rashi limited the iterations to 19 to account for a worst case scenario of virtually no mixing,3 in which case more than 19 iterations would still involve at least a safeik that the mikva is biblically valid.
However, if we could assume that the solution becomes perfectly mixed after each addition of fruit juice, we could use high school math to determine the maximum number of iterations after which the mikva would still remain biblically valid:
Suppose we want strictly more than 20 se'ah of water in the mikva solution. Denote the maximum number of allowable iterations n (∈ R). We can set up the inequality 40*(40/41)^n > 20 ⇒ (40/41)^n > .5 ⇒ log(base 40/41) of .5 < n ⇒ 1/(log(base 2) of 41 - log(base 2) of 40) < n. In this case n is slightly more than 28, so we can denote the integer-valued number of iterations as n' = sup{q ∈ Z | q ≤ n}, i.e. the largest integer less than or equal to n, namely 28.4
(Although I don't think logarithms were in use during Rashi's time, a close enough approximation for n could have been computed numerically in at most a matter of hours).
The halachic ramifications of this perfect mixing scenario are questionable, but I think this case could be used as a construct for a math problem.
1 Or temed, as the case may be. There are different interpretations as to what temed is, one being that it is a form of dilute wine made by soaking the sediment particulates from old wine in water. See Tosafos (s.v. nasan se'ah) for how this could affect the halacha. For the purposes of this answer, fruit juice is assumed to be the substance in question.
2 If Rashi meant that the solution must contain less that 20 se'ah of juice, he presumably would not have used the phrasing "he may do this until 19 se'ah," which implies an integer valued restriction.
3 Such as where 19 se'ah of fruit juice are added to one side of the mikva and 19 se'ah of solution are removed from the other side of the mikva in almost instantaneous succession. Although this seems to be an unfeasible feat, the limit would presumably be set at the edge of the possible rather than the feasible.
4 Please let me know if I made a math error. Incidentally, I wish Mi Yodeya had LaTeX support at times like this.