A diatonic function, in tonal music theory, is the specific, recognized role of each of the 7 notes and their chords in relation to the (diatonic) key. "Role" in this context means the degree of tension produced by a moving away to a note, chord or scale other than the tonic; and at the same time "how" this musical tension would be eased ("resolved") towards the stability of returning the tonic chord / note / scale (namely, "function").
Three general and inseparable essential features of harmonic function in tonal music are:
A fourth feature is the ambiguity that arises from the use of the same terms to describe functions across all temporal spans of a hierarchical structure from the surface to the deepest level, and that the longer term or deeper functions act as a center for shorter higher level ones and that the functions of each tend to counteract each other . "Harmonic function essentially results from the judgment that certain chords and tonal combinations sound and behave alike, even those these individuals might not be analyzed into equivalent harmonic classes," for example V and VII. "Harmonic function is more about...similarity than equivalence".
Each degree of a diatonic scale, as well as each of many chromatically-altered notes, has a different diatonic function as does each chord built upon those notes. A pitch or pitch class and its enharmonic equivalents have different meanings. For example, a C♯ cannot substitute for a D♭, even though in equal temperament they are identical pitches, because the D♭ can serve as the minor third of a B♭ minor chord while a C♯ cannot, and the C♯ can serve as the fifth degree of an F♯ major scale, while a D♭ cannot.
In music theory, as it is commonly taught in the US, there are seven different functions. In Germany, from the theories of Hugo Riemann, there are only three, and functions other than the tonic, subdominant and dominant are called their "parallels" (US: "relatives"). See Functional harmony. For instance, in the key of C major, an A minor (chord, scale, or, sometimes, the note A itself) is the Tonic parallel, or Tp. (German musicians use only uppercase note letters and Roman numeral abbreviations, while in the US, upper- and lowercase are usually used to designate major or augmented, and minor or diminished, respectively.) In the US, it would be referred to as the "relative minor."
As d'Indy summarizes:
- There is only one chord, a perfect chord; it alone is consonant because it alone generates a feeling of repose and balance;
- this chord has two different forms, major and minor, depending whether the chord is composed of a minor third over a major third, or a major third over a minor;
- this chord is able to take on three different tonal functions, tonic, dominant, or subdominant.—
In the United States, Germany, and other places the diatonic functions are:
|Function||Roman Numeral||German||German abbreviation|
|Mediant||iii||Dominant parallel/Tonic counter parallel||Dp/Tkp|
|Leading/Subtonic||vii||incomplete Dominant seventh||diagonally slashed D7|
Note that the ii, iii, vi, and vii are lowercase; this is because in relation to the key, they are minor chords. Without accidentals, the vii is a diminished vii°.
In the US the minor mode or scale is considered a variant of the major, while in German theory it is often considered, per Riemann, the inversion of the major. In the late eighteenth-early nineteenth centuries a large number of symmetrical chords and relations were known as "dualistic" harmony. The root of a major chord is its bass note in first inversion or normal form at the bottom of a third and fifth, but, symmetrically, the root of a major chord is the US fifth of a first inversion minor chord, and the US root is the "fifth". The plus and degree symbols, + and o are used to denote that the lower tone of the fifth is the root, as in major, +d, or the higher, as in minor, od. Thus, if the major tonic parallel is the tonic, with the fifth raised a whole tone, then the minor tonic parallel is the tonic with the US root/German fifth lowered a whole tone. 
|Parallel||Note letter in C||US name||Parallel||Note letter in C||US name|
|Tp||A minor||Submediant||tP||Eb major||Mediant|
|Sp||D minor||Supertonic||sP||Ab major||Submediant|
|Dp||E minor||Mediant||dP||Bb major||Subtonic|
If chords may be formed by raising (major) or lowering (minor) the fifth a whole step, they may also be formed by lowering (major) or raising (minor) the root a half-step to wechsel, the leading tone or leitton. These chords are Leittonwechselklänge, sometimes called gegenklang or "contrast chord". 
Another theory regarding harmonic functionality is that "functional succession is explained by the circle of fifths (in which, therefore, scale degree II is closer to the dominant than scale degree IV)." According to Goldman's Harmony in Western Music, "the IV chord is actually, in the simplest mechanisms of diatonic relationships, at the greatest distance from I. In terms of the circle of fifths, it leads away from I, rather than toward it." Thus the progression I-ii-V-I would comply more with tonal logic. However, Goldman , as well as Jean-Jacques Nattiez, points out that "the chord on the fourth degree appears long before the chord on II, and the subsequent final I, in the progression I-IV-viio-iii-vi-ii-V-I."  Goldman also points out that, "historically the use of the IV chord in harmonic design, and especially in cadences, exhibits some curious features. By and large, one can say that the use of IV in final cadences becomes more common in the nineteenth century than it was in the eighteenth, but that it may also be understood as a substitute for the ii chord when it precedes V. It may also be quite logically construed as an incomplete ii7 chord (lacking root)."  However, Nattiez calls this, "a narrow escape: only the theory of a ii chord without a root allows Goldman to maintain that the circle of fifths is completely valid from Bach to Wagner." 
Functions during or after modulations and especially tonicizations are often notated in relation to the function, in the original key, which the tonicization was to. Sometimes called "function of function", for example, in C major, a D major chord root is notated as II, but during a tonicization on G major, it would be notated, as in G major, V, as it is the dominant of (in C major) the dominant, it is notated V/V (five of five). For example, the twelve bar blues turnaround, I-V-IV-I, considered tonally inadmissible, may be interpreted as a doubled plagal cadence, IV/V-V-IV-I (IV/V-I/V, IV/I-I/I).
From the viewpoint of musical behaviour or structure there are three essential functions:
Other functions serve to support the Tonic and Dominant functions listed above:
The dominant, dominant preparation and the tonic substitution all involve more than one scale degree with only the tonic and subdominant containing only one scale degree. Several scale degrees exercise more than one function. 
The tonic includes four separate activities or roles as the: