The harmonic and melodic minor scales originate from classical music, and were heavily used in it; they were even used in certain Jazz passages to some extent. However, they found their way into metal, primarily through the music of Uli Jon Roth, Ritchie Blackmore, Yngwie Malmsteen, and Randy Rhoads, who have all paved the way for what is commonly referred to as neoclassical metal; a form of music which combines pleasant sound of classical music with the heavy sound of rock and metal.
Neoclassical metal was very popular and influential in the ever-so popular 80s shred scene(although shredding began earlier but it was far more popular in that time period). Players like Jason Becker, Marty Friedman, and George Lynch employed classical music in their own. Other than the standard major and minor scales and their modes, two scales were further added to the guitarists’ soloing arsenal; the harmonic and melodic minor scales.
It’s obvious that these scales are both variations of the minor scale (not modes of it). The harmonic minor scale is a minor scale with a major 7th, so it would have the following notes: 1 2 3b 4 5 6b 7. So if we were to take the A harmonic minor scale into consideration, it would be A B C D E F G#. So now there’s a half-step between the major 7th and the tonic, and the tension caused by this slight modification is noticeable, which leads to several options.
Now, this is where things might be a bit tricky but here it goes. If we take the notes B, D, F, and G#, we notice that the interval between each pair of consecutive notes is a minor 3rd. If we were to construct a chord from these four notes, we’d get what is called diminished 7th chord each time which has the following form (1, 3b, 5b, 7bb). The reason this is achievable is because the chord is symmetrical; the distance separating any pair of consecutive notes in it is the same. So playing any of these diminished 7th chords would work well with the harmonic minor scale. This approach is found in most of Yngwie Malmsteen’s songs, and he even claims that it’s the “bread and butter”, as he phrased it, of what he does. It gives a nice dissonant Eastern sound, which a lot of shredders like to use. It actually sounds good on many instruments including the piano, where a player could descend using a diminished 7th chord.
The melodic minor scale is slightly different; not only does it contain a major 7th, but a major 6th as well(the latter which is found in the Dorian mode). So A melodic minor would be A B C D E F# G#. And the using the diminished concept as the one in the harmonic minor scale doesn’t work here because the intervals separating the notes are different. This sound of the scale fluctuates between a positive and a negative nature, depending on how it’s used. It’s not commonly used as the harmonic minors scale, but it has its areas of usage, namely in fusion and more experimental forms of metal.
As usual, it is essential to experiment with scales in different sequences and over various chord progressions to discover how they work and when to use them. This is the best way to actually “understand” a scale.