a = Price of A; b = Price of B; x1 = Number of A at time 1; x2 = Number of A at
time 2; y1 = Number of B at time 1; y2 = Number of B at time 2; k = Ratio of A
to the total (A+B)
V = value of your inventory = ax1 + by1 = ax2 + by2 (Note that ax2 + by2
contains only givens and no variables. Thus, V is a solvable constant.)
k = x1/(x1+y1)
Solving for y1, we get: y1 = ((1-k)/k)*x1 [formula for y1]
Substituting into our V = ax1 + by1, we get: ax1 + b((1-k)/k)*x1 = V
Thus, x1*(a + (b*(1-k))/k) = V
We can simplify the coefficient of x1 to: x1*(ak+b-bk)/k = V
Solving for x1, we get: x1 = kV/(ak+b-bk).
We can substitute this solution for x1 into our y1 formula above: y1 =
((1-k)/k)*(kV/ak+b-bk).
k can be simplified from the numerator and the denominator, so the formula for
y1 = ((1-k)*V)/(ak+b-bk).
Note that the denominators for x1 and y1 can be rearranged to [ka + (1-k)*b].
You will remember that k is the percentage of A to the total, so (1-k) is the
percentage of B to the total.
x1 = kV/(ak+b-bk)
y1=(1-k)V/(ak+b-bk)
This works for all generalizations of a,b,x2,y2, and k (k is a decimal
value).