# Compute base price of each item in a list of items given the total sales tax

I'm having a disagreement with a client that I think is relatively simple mathematics, but I'd like a third party to confirm or dispute my assertions. Here's the situation:

We have a list of N final prices p1, ..., pN. A final price is tax-inclusive and includes two kinds of tax:

• flat tax, which is the same for all items
• sales tax, which is a percentage of the item's price

That means that you can define the base price bk of an item to be

pk = (1 + t) · bk + t0

where t0 is the flat tax and t is the sales tax. Alternatively, you can define the price of an item to be

pk = bk + tk

pk = bk + t · bk + t0

bk = pk - tk

where tk is the tax for that item.

Now, the question is:

Given only a list of prices (p1, ..., pN) and the total tax T = t1 + ... + tk, can you determine (b1, ..., bn)? If so, how would you express this?

-
FWIW, my contention is that there aren't a sufficient number of independent equations to solve this without more information (namely the values of either t or t0 or one of the base prices). –  John Feminella Mar 1 '11 at 20:19
You are correct, except in the trivial case in which $p_1=p_2=\cdots=p_N$. –  Arturo Magidin Mar 1 '11 at 23:19

From the comment, it is clear that you want to figure this out without knowing either the value of $t$ or $t_0$.

With a single price for all items you can: the base price is just the total minus the taxes, divided by the number of items. In fact, you can compute the base price of any item whose final price $p_i$ is exactly $\frac{1}{N}$th the total amount paid, $P=p_1+\cdots+p_N$.

But if you have at least two distinct prices among $p_1,\ldots,p_N$, then you cannot without knowing $t$ or $t_0$, or at least one $b_i$ that does not correspond to a $p_i$ that is exactly $\frac{1}{N}$th of $p_1+\cdots+p_N$. Below is the mathematical development of how to obtain examples, but of course to convince your client that this cannot be done, it will suffice to come up with an example in which the same set of data leads to two different possibilities. If that's all you need, you can skip to the paragraph that begins "So, to construct an example ..."

Corrected.

If the original prices are $(b_1,\ldots,b_N)$, with $B=b_1+\cdots+b_N$, then the total tax on them is $T = tB+Nt_0$. You also know $P=p_1+\cdots+p_N$, so you also know $(1+t)B + Nt_0$. Thus, $P-T = (1+t)B+Nt_0 - (tB+Nt_0) = B$. So we know $B$.

Since $T = tB + Nt_0$ and you know $T$, $B$, and $N$, you can parametrize $t_0$ in terms of $t$: solving for $Nt_0$ we get $Nt_0 = T-tB$.

So each choice of $t$ for which $T-tB\gt 0$ gives a possible choice for $t_0$ that will maintain the same tax.

But you also know $p_i$ for each $i$. Since $$p_i = (1+t)b_i + t_0 = (1+t)b_i + \frac{1}{N}\left(T-tB\right)$$ and since you know $B$, $T$, $N$, and have fixed a value of $t$, you get $$b_i = \frac{1}{1+t}\left(p_i + \frac{1}{N}(tB-T)\right) = \frac{Np_i + tB-T}{N(1+t)}.$$

Each selection of $t$ will give you a value for $b_i$ as above. If you add up the $b_i$ you get $B$; and if you take $(1+t)b_i + t_0$, you will get $$p_i + \frac{1}{N}(tB-T) + t_0 = p_i$$ (since $t_0 = \frac{1}{N}(T-tB)$). Moreover, the tax paid in this case will be \begin{align*} \sum(tb_i) + T-tB &= \sum((1+t)b_i - b_i) + T-tB = \sum(p_i) - \sum b_i + T-tB \\ &= P-B+T-tB = P-(1+t)B+T = T \end{align*} again the right answer.

Will different choices of $t$ yield the same base prices? Not in general. Because if $b_i$ is the value obtained by using $t$ and $b_i'$ is the value obtain by using $t'$, with $t\neq t'$, then setting $b_i=b_i'$ we get \begin{align*} \frac{Np_i+tB-T}{N(1+t)} &=\frac{Np_i+t'B-T}{N(1+t')}\\ (1+t')(Np_i+tB-T) &= (1+t)(Np_i+t'B-T)\\ Np_i + tB - T + t'(Np_i+tB-T) &= Np_i + t'B - T + t(Np_i+t'B-T)\\ (t-t')B + (t'-t)(Np_i - T) &= 0\\ (t-t')(T + B - Np_i) &= 0 \end{align*} which occurs if and only if $Np_i =T+ B = P$, if and only if $Np_i = P$, that is, $p_i$ is exactly $\frac{1}{N}$th the total price. If that is the case, then all possible choices of $t$ will yield the same base price, namely $\frac{1}{N}(P-T)$. But for any $p_i$ which is not exactly $\frac{1}{N}$th of $P$ you will get different values of $b_i$ for each value of $t$.

Therefore, you can get different base prices with different sales tax rates (provided they satisfy $tB\leq T$, with $tB=T$ being the case where the flat tax is $0$).

So, to construct an example, consider the case where the final prices were $10$ and $20$, and the total tax was $3$. So $p_1 = 10$, $p_2 = 20$, $P=30$, $T=3$, $N=2$.

We know that the total base prices were $B = P-T = 27$. This leads to the equation $$2t_0 = 3 - 27t.$$ We want to select two distinct values of $t$ for which $3-27t\gt 0$. That is, $t\lt \frac{1}{9}$. Take $t=.1$.

If $t=.1$, then $2t_0 = 3-2.7 = 0.3$, so $t_0 = 0.15$. We have a 10% sales tax and a 15 cent flat tax. If this is the case, then \begin{align*} b_1 &= \frac{2p_1 + tB-T}{2(1+t)} = \frac{20+.1(27)-3}{2(1.1)} \approx 8.954\\ b_2 &= \frac{2p_2 + tB-t}{2(1+t)} = \frac{40+.1(27)-3}{2(1.1)} \approx 18.045. \end{align*} We can verify that this works: $\$ $8.95 plus a tax of 10% (rounded up) plus 15 cents gives$\10.0. And $\$ $18.05 plus a tax of 10% (rounded down, since we rounded up the price) plus 15 cents gives$\20.00. The total tax paid was $.90 + .15 + 1.80 + .15 = 3.00$.

Now take $t=0.08$. Then $2t_0 = 3-.08(27) = 0.84$, so now we have a sales tax of 6% and a flat tax of 42 cents. In this case, we get \begin{align*} b_1 &= \frac{2p_1 + tB - T}{2(1+t)} = \frac{20 + .08(27)-3}{2(1.08)} \approx 8.87\\ b_2 &= \frac{2p_2 + tB - T}{2(1+t)} = \frac{40 + .08(27) - 3}{2(1.08)} \approx 18.13 \end{align*} A base price of $\$ $8.87, plus an 8% sales tax (71 cents) plus 42 cents flat tax gives$\10.

A base price of $\$ $18.13, plus an 8% sales tax ($\1.45) plus 42 cents flat tax gives $\$ $20. The total tax is$0.71 + 0.42 + 1.45 + 0.42 = 3.00$, again as expected. So we get two possibilities: a 10% sales tax with a 15 cent flat tax, with base prices of$\8.95 and $\$ $18.05; or a sales tax of 8% and a flat tax of 42 cents, with base prices of$\8.87 and $\$ $18.13. Different base prices, same individual final prices, same total tax paid. Knowing a single base price$b_i$which does not correspond to a$p_i$with$Np_i=P$will also suffice, since from the equation $$p_i = (1+t)b_i + \frac{1}{N}\left(T-tB\right)$$ you can solve for$t$, knowing$p_i$,$N$,$T$, and$B$, provided only that$tb_i\neq \frac{B}{N}$, which occurs if and only if$p_i = \frac{P}{N}$. So in summary, without knowing at least one$b_i$that does not correspond to a$p_i$with$Np_i=P$, or knowing$t_0$, or knowing$t$, an at least one price$p_i$not$\frac{1}{N}$th of$P$, you cannot figure out the base prices. But if you know at least one of$t$,$t_0$, or a$b_i$with$Nb_i\neq B=P-T$, then you can (or if all$p_i\$ are equal).

-
Thank you very much for your thorough and complete answer. I was eventually able to get my client to agree that this wasn't possible by constructing a counterexample similar to yours. –  John Feminella Mar 2 '11 at 10:18