Density matrix treatment of BO2 and CO2