A firm produces good A and good B, and faces demand functions for these two goods:
qA = 1000 * (20 − pA)

qB = 1000 * (20 − pB)
Its total cost function is: TC (qA, qB) = 4(qA + qB)+ (qA+qB)2/4000

What are the profit-maximising quantities of the two goods to make and sell?

ANSWER: qA = qB = 5333.33. this is the answers but I want to know how the answer was obtained.
with many thanks.

Total profit is total revenue minus total cost. Revenue is units demanded times price per unit. Hence we have:

Total revenue:

$R\left(q_A,q_B \right)=20\left(q_A+q_B \right)-\frac{q_A^2+q_B^2}{1000}$

and so the total profit is:

$P\left(q_A,q_B \right)=R\left(q_A,q_B \right)-C\left(q_A,q_B \right)$

$P\left(q_A,q_B \right)=\left(20\left(q_A+q_B \right)-\frac{q_A^2+q_B^2}{1000} \right)-\left(4\left(q_A+q_B \right)+\frac{\left(q_A+q_B \right)^2}{4000} \right)$

$P\left(q_A,q_B \right)=16\left(q_A+q_B \right)-\frac{q_Aq_B}{2000}-\frac{q_A^2+q_B^2}{800}$

Next, find the partial derivatives and equate to zero to determine the critical points:

$P_{q_A}\left(q_A,q_B \right)=16-\frac{q_B}{2000}-\frac{q_A}{400}=0$

This implies: $5q_A+q_B=32000$

$P_{q_B}\left(q_A,q_B \right)=16-\frac{q_A}{2000}-\frac{q_B}{400}=0$

This implies: $5q_B+q_A=32000$

Together, these imply: $q_A=q_B=\frac{16000}{3}$