Halogens, sulphur and phosphorus are all estimated the same way: convert the element into one particular insoluble salt, weigh that salt, and scale back to find what fraction of the original compound was that element. This is the Carius method (for halogens and sulphur) and a closely related oxidation-and-precipitation method for phosphorus. In every case you need two masses — the mass of organic compound you started with, and the mass of the final weighable salt — because the percentage formula is built entirely from that ratio and the known molar mass of the salt.
1. Estimation of halogens (Carius method)A known mass of the organic compound is heated with fuming nitric acid, \(\displaystyle \text{HNO}_3 \), in the presence of silver nitrate, \(\displaystyle \text{AgNO}_3 \), inside a sealed hard-glass tube (the Carius tube). The carbon and hydrogen in the compound are oxidised away as carbon dioxide and water, while the halogen present is converted straight into the insoluble silver halide:
\[\text{Organic compound} + \text{HNO}_3 \xrightarrow{\text{AgNO}_3,\ \Delta} \text{CO}_2 + \text{H}_2\text{O} + \text{AgX}\ (\text{precipitate})
\]
Here \(\displaystyle X \) stands for the halogen (Cl, Br or I) present in the compound. This equation is not meant to be balanced atom-for-atom the way a normal reaction is, because "organic compound" is not one fixed formula — it is a bookkeeping statement of what happens to each type of atom: carbon and hydrogen end up oxidised, and the halogen ends up locked into \(\displaystyle \text{AgX} \), a solid that will not redissolve in the acidic solution.
The silver halide precipitate is filtered, washed, dried and weighed. Let \(\displaystyle m \) be the mass of organic compound taken and \(\displaystyle m_1 \) be the mass of \(\displaystyle \text{AgX} \) obtained. Since every mole of \(\displaystyle \text{AgX} \) contains exactly one mole of the halogen, the mass of halogen inside \(\displaystyle m_1 \) grams of \(\displaystyle \text{AgX} \) is found from the fraction of \(\displaystyle \text{AgX} \)'s molar mass that belongs to \(\displaystyle X \):
\[\%\ \text{of halogen} = \frac{\text{atomic mass of } X}{\text{molar mass of AgX}} \times \frac{m_1}{m} \times 100
\]
The step people get wrong here is treating \(\displaystyle m_1 \), the mass of AgX, as if it were the mass of halogen itself. It is not — \(\displaystyle \text{AgX} \) also contains the mass of silver, so you must always multiply by the atomic-mass fraction \(\displaystyle \dfrac{\text{atomic mass of }X}{\text{molar mass of AgX}} \) before you can call the number "mass of halogen."Using atomic masses \(\displaystyle \text{Ag} = 108,\ \text{Cl} = 35.5,\ \text{Br} = 80,\ \text{I} = 127 \):
\[\%\ \text{Cl} = \frac{35.5}{143.5}\times\frac{m_1}{m}\times100,\quad
\%\ \text{Br} = \frac{80}{188}\times\frac{m_1}{m}\times100,\quad
\%\ \text{I} = \frac{127}{235}\times\frac{m_1}{m}\times100
\]
(the denominators $\displaystyle 143.5$, $\displaystyle 188$ and $\displaystyle 235$ are the molar masses of \(\displaystyle \text{AgCl} \), \(\displaystyle \text{AgBr} \) and \(\displaystyle \text{AgI} \) respectively).
2. Estimation of sulphur (Carius method)The same Carius-tube procedure is used: a known mass of the compound is heated with fuming nitric acid, but this time the sulphur present is oxidised all the way to sulphuric acid:
\[\text{S (in compound)} + \text{HNO}_3 \xrightarrow{\Delta} \text{H}_2\text{SO}_4
\]
The resulting sulphuric acid is then precipitated as barium sulphate by adding excess barium chloride solution:
\[\text{H}_2\text{SO}_4 + \text{BaCl}_2 \longrightarrow \text{BaSO}_4\downarrow + 2\text{HCl}
\]
Checking this balances: $\displaystyle 1$ Ba, $\displaystyle 1$ S and $\displaystyle 4$ O appear on each side, and the $\displaystyle 2$ chlorines on the left reappear as $\displaystyle 2$ HCl on the right — so the coefficient $\displaystyle 2$ in front of HCl is what makes it balance, not 1.
The white \(\displaystyle \text{BaSO}_4 \) precipitate is filtered, washed, dried and weighed. With \(\displaystyle m \) = mass of compound and \(\displaystyle m_1 \) = mass of \(\displaystyle \text{BaSO}_4 \) formed, and using \(\displaystyle \text{Ba}=137,\ \text{S}=32,\ \text{O}=16 \) so that the molar mass of \(\displaystyle \text{BaSO}_4 = 137+32+64 = 233 \):
\[\%\ \text{of sulphur} = \frac{32}{233}\times\frac{m_1}{m}\times100
\]
The same aside applies again: \(\displaystyle m_1 \) is the mass of the whole \(\displaystyle \text{BaSO}_4 \) salt, not the mass of sulphur — the factor \(\displaystyle \dfrac{32}{233} \) is what strips out the barium and oxygen to leave just the sulphur's share.3. Estimation of phosphorusA known mass of the organic compound is heated with fuming nitric acid, which oxidises the phosphorus present to phosphoric acid:
\[\text{P (in compound)} + \text{HNO}_3 \xrightarrow{\Delta} \text{H}_3\text{PO}_4
\]
This phosphoric acid is precipitated as magnesium ammonium phosphate by adding magnesia mixture (a solution of \(\displaystyle \text{MgCl}_2 \) and \(\displaystyle \text{NH}_4\text{OH} \)):
\[\text{MgCl}_2 + \text{NH}_3 + \text{H}_3\text{PO}_4 \longrightarrow \text{MgNH}_4\text{PO}_4\downarrow + 2\text{HCl}
\]
(Balance check: $\displaystyle 1$ Mg and $\displaystyle 1$ P on each side; hydrogens total \(\displaystyle 3+3=6 \) on the left and \(\displaystyle 4+2=6 \) on the right; the $\displaystyle 2$ chlorines on the left match the $\displaystyle 2$ in \(\displaystyle 2\text{HCl} \).)
The \(\displaystyle \text{MgNH}_4\text{PO}_4 \) precipitate, once filtered and washed, is ignited (strongly heated), which converts it to magnesium pyrophosphate, \(\displaystyle \text{Mg}_2\text{P}_2\text{O}_7 \) — this is the compound actually weighed, because \(\displaystyle \text{MgNH}_4\text{PO}_4 \) itself is not stable enough on heating in air to give a reliable mass:
\[2\text{MgNH}_4\text{PO}_4 \xrightarrow{\Delta} \text{Mg}_2\text{P}_2\text{O}_7 + 2\text{NH}_3\uparrow + \text{H}_2\text{O}
\]
(Balance check: Mg \(\displaystyle 2=2\); N \(\displaystyle 2=2\); P \(\displaystyle 2=2\); H on the left \(\displaystyle 2\times4=8\), on the right \(\displaystyle 2\times3 + 2 = 8\); O on the left \(\displaystyle 2\times4=8\), on the right \(\displaystyle 7+1=8\).)
With \(\displaystyle m \) = mass of compound and \(\displaystyle m_1 \) = mass of \(\displaystyle \text{Mg}_2\text{P}_2\text{O}_7 \) finally weighed, and using \(\displaystyle \text{Mg}=24,\ \text{P}=31,\ \text{O}=16 \), so molar mass of \(\displaystyle \text{Mg}_2\text{P}_2\text{O}_7 = 2(24)+2(31)+7(16) = 48+62+112 = 222 \), and noting that each mole of \(\displaystyle \text{Mg}_2\text{P}_2\text{O}_7 \) carries
two phosphorus atoms:
\[\%\ \text{of phosphorus} = \frac{2\times31}{222}\times\frac{m_1}{m}\times100 = \frac{62}{222}\times\frac{m_1}{m}\times100
\]
Here the mistake to avoid is using only one atomic mass of phosphorus ($\displaystyle 31$) in the numerator instead of \(\displaystyle 2\times31=62\) — the weighed salt \(\displaystyle \text{Mg}_2\text{P}_2\text{O}_7 \) has two phosphorus atoms per formula unit, so leaving out that factor of $\displaystyle 2$ would understate the phosphorus content by half.Answer: In all three estimations, a known mass \(\displaystyle m \) of the organic compound is oxidised (heated with fuming \(\displaystyle \text{HNO}_3 \), for halogens in the presence of \(\displaystyle \text{AgNO}_3 \)) so that the element of interest is converted into one specific insoluble, weighable salt of mass \(\displaystyle m_1 \): the halogen as \(\displaystyle \text{AgX} \), sulphur as \(\displaystyle \text{BaSO}_4 \) (via \(\displaystyle \text{H}_2\text{SO}_4 + \text{BaCl}_2 \rightarrow \text{BaSO}_4\downarrow + 2\text{HCl} \)), and phosphorus as \(\displaystyle \text{Mg}_2\text{P}_2\text{O}_7 \) (via \(\displaystyle \text{H}_3\text{PO}_4 \rightarrow \text{MgNH}_4\text{PO}_4\downarrow \xrightarrow{\Delta} \text{Mg}_2\text{P}_2\text{O}_7 \)). The percentage of each element is then \(\displaystyle \%\ \text{element} = \dfrac{\text{mass of element in one mole of the salt}}{\text{molar mass of the salt}} \times \dfrac{m_1}{m} \times 100 \), giving \(\displaystyle \%\text{X} = \dfrac{\text{at. mass of X}}{\text{molar mass of AgX}}\times\dfrac{m_1}{m}\times100 \), \(\displaystyle \%\text{S} = \dfrac{32}{233}\times\dfrac{m_1}{m}\times100 \), and \(\displaystyle \%\text{P} = \dfrac{62}{222}\times\dfrac{m_1}{m}\times100 \).