Where does the energy of formation of covalent bonds come from?

Consider two $\ce{H}$ atoms. Since the proton in one attracts the electron in another, they attract each other, and form a covalent bond ($\ce{H-H}$). Bond forming requires energy (436 kJ/mol for an $\ce{H-H}$ bond) – where does that energy come from?
If I put two $\ce{H}$ atoms in a container, would they form an $\ce{H-H}$ bond by themselves, or would I need to add energy to the system in order for them to bond?

• What do you mean where does the energy come from? – M.A.R. Dec 27 '14 at 10:18
• Energy is conserved, so something in there has got to lose joules to form the bond. Who loses it? (Or correct me if my physics is wrong) – blz Dec 27 '14 at 10:28
• Nah, merry christmas. :) It doesn't really have to be something; it's just the thermodynamic system that will gain energy. Don't get me wrong, energy is released when new bonds form. You're only talking about something like H to H bonds, right? – M.A.R. Dec 27 '14 at 10:41
• You might find Terry Bollinger's answer to a similar question helpful. – Klaus-Dieter Warzecha Dec 27 '14 at 11:11
• Two hydrogen atoms forming a bond doesn't require an input of energy, it releases energy which is why most actual elemental hydrogen under earthly conditions is found as H2 hydrogen molecules. – matt_black Dec 27 '14 at 14:49

Your view of bonding is a little simplified and confused. For the details it is worth reading the great answer referred to in some comments already: Fundamental forces behind covalent bonding .

I'll stick with a simpler view that focusses just on the energy involved and not the mechanism of chemical bonding. Firstly, you are wrong that boding two hydrogen atoms needs an input of energy. It actually releases energy. This is a thermodynamic view of the reaction. This tells us whether there is more or less energy in the product of the reaction being described than in the chemicals being combined to create the product.

But a lot of chemical reactions are thermodynamically favourable (that is the reaction releases energy) don't happen easily (this is probably not true for atomic hydrogen which should react very easily to form H2). But there are plenty of other reactions that release energy according to thermodynamics but that don't happen easily. For example, elemental carbon plus oxygen will release energy if converted to CO2. But neither the diamond in jewellery or the coal in your fireplace (which is basically impure carbon) reacts easily to give carbon dioxide despite being in an environment with a lot of Oxygen gas in it. Here the problem is that room temperature oxygen molecules and carbon just don't have enough energy to kick off the process that creates the product. This is where we have to look at the kinetic view of the reaction rather than just the thermodynamics. Although the overall reaction is favourable according to thermodynamics, we need to add energy (firelighters for coal fires, a blowtorch or diamond rings) to the mixture to give the atoms in the reactants enough energy to overcome the kinetic barriers to the reaction. Think of having to climb a tall mountain to get to a lower valley on the other side. Or think of giving oxygen molecules enough energy to break carbon atoms apart from their normal solid structure.

Once coal or diamond are warm enough, the reaction will happen spontaneously and you have either destroyed your engagement ring or you have a nice coal fire. In this case you can feel the energy released from the reaction as a pleasant warming of your room.

Back to the question. The energy involved in a reaction is an accounting of the amount of energy used in the bonding of the products versus the reactants. The energy released in reactions such as burning carbon goes into the environment as heat. Other reactions happen spontaneously (try dropping a small lump of sodium into water). Some reactions require a tiny amount of encouragement (oxygen and hydrogen in certain concentrations will react explosively to form water when encouraged with the tiniest spark).

We can drive some reactions the other way using inputs of energy. For example we can electrolyse water into a mixture of hydrogen and oxygen. This requires us to add energy to the system (about 286kJ/mol) because the products are in a higher energy state then the reactants.

If you just focus on the thermodynamics of a reaction the numbers (kcal or kJ/mol) tell you how much the energy difference between the products and reactants is. But many reactions that should release energy require some input to kick off the reaction. This is confusing, but chemistry wouldn't be interesting and we wouldn't exist if thermodynamics were the only thing driving reactions.

Also energy is not created or destroyed here, just moved around. You can put energy in to a system to drive a reaction or the environment gets energy back from reactions that release it.

So, some reactions require energy to drive them because the products have higher energy, some release energy because the products have lower energy but many release energy but, confusingly, require some energy input to kick off the actual reaction process.

As others have mentioned energy is released on bonding, which is why $H_2$ is more stable that two H atoms. To answer your last question first, H atoms in a box would eventually form $H_2$ but only if some third body (another H atom or wall of vessel) can take away some of the energy released before the H atoms fly apart again. This leaves $H_2$ in a highly vibrational state, further collisions will remove the remaining energy until it is at equilibrium with its surroundings.

Now as to bond formation, its easier to examine $H_2^+$, this has two protons and one electron; the simplest possible bond. The calculation involves evaluating the interaction between the two protons and either proton and the electron. These are of the coulomb type, that is product of charges divided by separation. (No complications from Pauli principle here as there is only one electron.)

Solving Schroedinger's equation involves terms with kinetic and potential energy (this is the Hamiltonian $H_0$). The terms for electron proton interaction are negative ($-e^2/r_1 - e^2/r_2$, where e is the electronic charge and $r_1$ the distance of proton 1 to the electron and similarly for $r_2$)) and the potential energy between protons is $+e^2/R$ where R is the internuclear separation).

The calculation proceeds by technical steps, say by using the variational theorem, and integrating over all distances and angles and distances using a basis set of atomic wavefunctions, call them $\phi_1$ and $\phi_2$.(for details see Cohen-Tannoudji, Diu & Laloe, Quantum Mechanics vol II for a full calculation).

We find that there are Coulomb integrals of the form $\int \phi_1\frac{e^2}{r_2} \phi_1 d\tau$, and $\int \phi_2\frac{e^2}{r_1} \phi_2 d\tau$. ($d \tau$ simply means integrate over all coordinates). These give the energy of the electrostatic interaction between proton 2 and charge distribution of the electron were it in the 1s orbital of proton 1 and vice versa.

In addition there are integrals of the form $A=\int \phi_1\frac{e^2}{r_1} \phi_2 d\tau$ which have no classical equivalent, i.e. they would not arise in a classical calculation. These are sometimes called 'resonance integrals' or 'exchange integrals' although this latter term can mean something else to physicists. The integral A is difficult to explain, other than to say that it arises out of the mathematics used when making a linear combination of atomic orbitals. The fact that integral A is not zero expresses the possibility of the electron ' jumping' as it were from the neighbourhood of one proton to that of the other and hence the possibility of 'quantum resonance' (The term 'resonance' arises by analogy with oscillating pendulums, see Coulson, Valence chapter 4 but does not imply actual motion).

The combination of these integrals (and the overlap integral $S=\int \phi_1\phi_2 d\tau$) produces a minimum in the potential energy profile as the calculation is repeated at different internuclear separations R and hence describes the energy of the $H_2^+$ molecule vs. separation of the nuclei.

The total energy comprises kinetic and potential energy terms, so is it the decrease in kinetic energy or potential energy that is responsible for the chemical bond? The overwhelming effect is due to the decrease in potential energy. This is also confirmed by Virial Theorem calculations.

In the $H_2$ molecule we can carry over what has been done for $H_2^+$. Now we have two valence electrons instead of one, they will both occupy an orbital similar to that in $H_2^+$ and the electrons will have opposite spins by Pauli Principle. The main difference is that there are now two electron contributing to binding and the bond if stronger. The essential principles outlined here can be carried through to forming bonds between other atoms although the calculations become tremendously more involved as there are many more electrons.