Best way to account for pH and Total Alkalinity interplay?

I’m asking about this recipe:
https://pooldash.com/recipe/vast_argument_756/edit

If you scroll down to look at the formulas for soda_ash and baking_soda, you can see exactly what I’m referring to.

Basically, the pH and TA are closely related. This recipe accounts for this by:

  1. Raising the pH using soda ash (which has a stronger affect on pH, and a weaker effect on TA).
  2. Calculating how much of an effect that soda ash will happen to have on the TA
  3. If that effect isn’t enough, raising the TA using an appropriate amount baking soda.

This works for many scenarios, but there are a few gaps. For instance, there could be some instances where starting with baking soda would be optimal. Also, the final dose of baking soda might raise the pH undesirably high, especially in scenarios where the starting pH is high but the TA is low.

The formulas themselves also fail to account for much interplay between the 2 chemicals. For instance, the higher the TA, the more resistant to change the pH will be. In practice, this doesn’t affect dosing much, because we’re generally moving the pH by less than 1, and there is a decently wide margin-of-error where we can still arrive to the ideal range.

Still, I’m open to thoughts / suggestions, and if someone wants to “remix” this recipe and publish it, I’d be thrilled to take a look.