The question in the original post was "Is there a formula to get this exact" and the answer is "yes" under certain conditions. It just never dawned on me how simple it is so there's two Homer Simpson moments for me from this thread. There are some caveats which we will get to but here are the formulas. The first one gives the number of millimoles of CaCl2 to add to the water to increase the calcium content by Ca mmol, the chloride content by Cl mmoi, the magnesium content by Mg mmol, the sodium content by Na mmol and the sulfate content by SO4 mmol. The second line gives the number of mmol of CaSO4 to be added for the same desired increases in the individual ions, the third the mmol of table salt and the fourth the mmol of MgSO4. Note that waters of hydration are not specified. When the formula give you the number of mmol of CaCl2 to add it means that you must provide that many mmol of CaCl2 and calculate the weight of CaCl2 corresponding to that by including the water of hydration if any. The same applies to gypsum (2 H20) and Epsom salts (7 H2O).
CaCl2 = 0.142857*Ca + 0.428571*Cl + 0.142857*Mg -0.428571*Na -0.142857*S04
CaSO4 = 0.571429*Ca -0.285714*Cl -0.428571*Mg + 0.285714*Na +0.428571*S04
NaCl = -0.142857*Ca + 0.0714286*Cl -0.142857*Mg + 0.928571*Na + 0.142857*S04
MgSO4 = -0.285714*Ca + 0.142857*Cl +0.714286 *Mg -0.142857*Na + 0.285714*S04
Now the caveats:
First, obviously, I'm only giving you the ability to add CaCl2, CaSO4, NaCl and MgSO4. No acids, sodium bicarbonate, calcium hydroxide or any other salt can be used. The simple formula works for any salt that does not change the pH of the mix. Any addition that does renders the problem non-linear and takes away this simple solution. Clearly we could extend to salts like KCl, NaSO4, MgCl2...
Second, you can't always get what you want because the ions are paired in the salts in fixed proportion. For example 1 mmol of CaCl2 contains 1 mmol Ca++ and 2 mmol of Cl-. Thus, if, for example, you want to increase calcium by 2 mmol, chloride by 3, magnesium by 1, sodium by 1 and sulfate by 2 and put those numbers into the formulas they will tell you to add 1 mmol of each of the 4 salts and it ought to be clear that doing so will add the amounts of the ions we just specified. In the following formulas Ca, for example, represents the increase in mmol of calcium from an addition of CaCl2 mmol of calcium chloride, CaSO4 mmol of calcium sulfate, NaCl mmol of sodium chloride and MgSO4 mmol of magnesium sulfate.
Ca = 1*CaCl2 + 1*CaSO4 + 0*NaCl + 0*MgSO4
Cl = 2*CaCl2 + 0*CaSO4 + 1*NaCl + 0*MgSO4
Mg= 0*CaCl2 + 0*CaSO4 + 0*NaCl + 1*MgSO4
Na= 0*CaCl2 + 0*CaSO4 + 1*NaCl + 0*MgSO4
SO4= 0*CaCl2 + 1*CaSO4 + 0*NaCl + 1*MgSO4
If, OTOH, you want to increase calcium by 2.2 mmol, chloride by 3, magnesium by 1, sodium by 1 and sulfate by 2 and put those numbers into the formulas you will get answers telling you to add, respectively for the four salts 1.02857, 1.11429, 0.971429, and 0.942857 mmol. If you put those numbers into the second set of equations you will find that they give you
Ca = 2.14286, Cl = 3.02857, Mg = 0.942857, Na = 0.971429 and SO4 = 2.05714. This is not quite what you wanted but pretty close. You have asked the impossible and the formulas cannot, therefore, give you exactly what you want but they do give you the best answer they can (in the rms sense) under the circumstances. You should always put the answers you get back into the second set of formulas in order to see how close you can get to what you want.
Third, if you make really foolish demands such as for 2 mmol of sulfate with only 0.1 mmol of Calcium and 1 mmol of everything else the formulas will blithely compute a calcium chloride addition of -0.12 mmol. This is, of course, impossible to do chemically (but not mathematically).
Some of you will have figured out how this works. The column vector
Ca
Cl
Mg
Na
SO4
in which the chemical symbols represents the mmol increase in the named ion, is the product of the matrix
1 1 0 0
2 0 1 0
0 0 0 1
0 0 1 0
0 1 0 1
with the column vector
CaCl2
CaSO4
NaCl
MgSO4
where the chemical symbols represent the mmol of added salt. The numbers in the first set of formulas clearly represent another matrix which is the Moore - Penrose pseudo-inverse of this matrix. We have to use the pseudo-inverse because we have 5 equations in 4 unknowns and these equations may not be consistent (and indeed often aren't in most cases). But the beauty of this is that when they are not consistent, we get the best solution possible even though our demands were unreasonable. I have often though about looking into this but never did. The huge insight is, of course, that the matrix is always the same for a given set of salts so that the pseudo-inverse only has to be computed once. The dumb and proud of it crowd don't even have to know where the numbers came from. They can just plug into the formulas.