Resultant frequency if 3 harmonic notes (a chord) is played If I know the frequency of individual notes being played (let's assume D, F# and A), how do I determine the final frequency if they are played (nearly) simultaneously as a chord. 
To put the problem in context, I am writing a program where user inputs are classified and chords are played as output. My programming knowledge is limited (my degrees are in biochemistry and neuroscience), and the help file gave me the following options:


*

*Play a frequency

*Use a recording for playback


As I do not wish to use the second option, I was wondering how to calculate the resulting frequency or to represent resultant sound mathematically. If someone could explain the theory behind this or post a link for the same, I'd be especially grateful.
 A: Here's a minimum working example of a python program which generates a .wav file with a major triad of 440:550:660 Hz using sine waves. Your user input could be used to generate any frequencies for the chord. 
import math, wave, array
duration = 1 # seconds
freq1 = 440 # tonic (Hz) (frequency of the sine waves)
freq2 = 550 # 2nd note
freq3 = 660 # 3nd note
amp1 = 0.2 # amplitude of freq1; sum of amplitudes should be <= 1
amp2 = 0.2 # amplitude of freq2
amp3 = 0.2 # amplitude of freq 3
volume = 100 # percent
data = array.array('h') # signed short integer (-32768 to 32767) data
sampleRate = 44100 # of samples per second (standard)
numChan = 1 # of channels (1: mono, 2: stereo)
dataSize = 2 # 2 bytes because of using signed short integers => bit depth = 16
numSamplesPerCyc = int(sampleRate / freq1)
numSamples = sampleRate * duration
factor=2*math.pi/sampleRate
for i in range(numSamples):
    sample = 32767 * float(volume) / 100
    sample *= amp1*math.sin(factor*freq1* i)+ amp2*math.sin(factor*freq2*i)+amp3*math.sin(factor*freq3*i)
    data.append(int(sample))
f = wave.open('SineWave_' + str(freq1) + 'Hz.wav', 'w')
f.setparams((numChan, dataSize, sampleRate, numSamples, "NONE", "Uncompressed"))
f.writeframes(data.tostring())
f.close()
print "Done"

A: Well, you ask for a "resultant sound"  but, in fact, when you play a note, for example A4, not only one sound is played. 
In theory, a wave can be represented as a sine, a simple oscillation. For example, a wave propagating on a string can have the following form:
$$y(x,t)=A\sin(2\pi ft-kx)$$
Where $f$ is the frequency of your sound (A4 = 440 Hz, for example) and $k$ is related with string properties, as density.
In an ideal string, a single wave of that type can be propagated. This wave correspond to a vibration mode (the number of cycles of the wave). However, on a real string, when you play a violin, for example, a lots of vibrations modes vibrate at the same time. Which ones? The corresponding to the harmonic series. 
That means that when play, for example A note, the 440 A vibrates very strong. But also the A5 and E5, and C#5, in less intensity (and many more frequencies, with lower intensity). 
So when you play a note you hear more than one sound. This is the difference between piano and violin, for example. If you see which frequencies are sounding and which is its intensity when you play A, you'll realize that there're differences. That's why every instrument has its proper soundwave. In order to have a realistic sound you must try to imit the spectrum of an instrument, which is really difficult (and that's why recordings of real instruments are very used).
In a chord, you don't only get the sum of all the harmonics of every sound, but an superposition of them, which makes the thing even more complex. 
For example, in a orchestra, "undesired harmonics" can arise when metals are playing a big chord. The superposition of sounds can give intensity to a frequency which is not on the chord, making it sound awful. Good composers know how to avoid this things by a correct voice conduction.
The example someone gave on Python will be functional, and you'll obtain a good sound, because fundamental frequency is the most important. Note the example writes every sound as a simple sine wave. But the real waves are something more complex. You can try to approximate the real sounds as a sum of the frequencies of the harmonic series, using sines. And then combine this to create a chord.
To do this (it is not easy!) you can read about Fourier Series.
Only for your curiosity, this complex waves are called waves packets and the harmonics can be analyzed using Fourier Analysis. In Neuroscience it may be useful to analyze electric signals from the brain ;D
A: A chords does not have a single frequency as it consists of three notes of different frequencies being played at the same time. It may sounds like a single note to you since the three frequencies that make up the chords have to be in harmony.
If you wish to play a certain tune or song using only single frequencies I would suggest you only play the root note of each chords rather than the full chord. This gives you the typical monotone ringtone sounds from the 90s.
A: You know that a single note in an instrument contains multiple frequencies and harmonics. The wave shape is never an ideal sine wave carrying one frequency. So combining two notes can be done with a convolution integral.
You convert each note to the frequency domain via a Fourier transform and combine the signals using the convolution integral. In the end you have the frequency spectrum of the resulting sound.
