This is a simulation of two wave pulses moving along the same string in opposite directions. When the two pulses overlap, their sum is shown on the bottom black string. The sum at any given point along the string is simply the sum of the displacements from equilibrium of each of the individual pulses at that point. This is called the principle of superposition.