An interval is the distance between two notes. An interval is not the same when moving up and down, i.e. if you move up a fifth and then down a fifth you will not return to the starting note. To get back to the starting note, you need to invert the interval. (There is an exception regarding the tritone to be discussed below.)

Inverting an interval changes its numeric name, i.e. a second becomes a seventh, a third becomes a sixth, and a fourth becomes a fifth. The numbers associated with the numeric name of the original and the inverted interval always add up to 9. 2+7=9 (Second/Seventh), 3+6=9 (Third/Sixth), 4+5=9 (Fourth/Fifth).

Inverting an interval usually changes the quality of the interval. If it was a major interval before the inversion, it becomes a minor interval afterward, and vice-versa. Similarly, an augmented interval becomes diminished, and vice-versa. The only intervals which do not change qualities when inverted are perfect intervals, which retain their quality but not their numeric name. For example, a perfect fourth interval, when inverted, becomes a perfect fifth. Though the name changes from a fourth to a fifth, the “perfect” quality is unchanged.

To be clear, that means when you move up a perfect fifth, to return to your starting pitch you would move down a perfect fourth. Likewise, when you move up a major third, to return to your starting pitch you would move down a minor sixth.

A diminished fifth (also known as a tritone) is the only interval that has the same number of half-steps (6) when inverted to an augmented fourth (6 half-steps), even though the quality changes from diminished to augmented. That makes it the only interval that would return you to your starting pitch in both directions.

The following are inversions of each other:
Minor Second and Major Seventh
Major Second and Minor Seventh
Minor Third and Major Sixth
Major Third and Minor Sixth
Perfect Fourth and Perfect Fifth
Augmented Fourth and Diminished Fifth

Minor Second/Major Seventh
1♭2
2
♭3
3
4
♭5
5
♭6
6
♭7
7
1
1→♭2 = 1 half-step (min2)♭2→1 = 11 half-steps (Maj7)1+11 half-steps = 1 octave
Major Second/Minor Seventh
1
♭2
2
♭3
3
4
♭5
5
♭6
6
♭7
7
1
1→2 = 2 half-steps (Maj2)2→1 = 10 half-steps (min7)2+10 half-steps = 1 octave

Minor Third/Major Sixth
1
♭2
2
♭3
3
4
♭5
5
♭6
6
♭7
7
1
1→♭3 = 3 half-steps (min3)♭3→1 = 9 half-steps (Maj6)3+9 half-steps = 1 octave
Major Third/Minor Sixth
1
♭2
2
♭3
3
4
♭5
5
♭6
6
♭7
7
1
1→3 = 4 half-steps (Maj3)3→1 = 8 half-steps (min6)4+8 half-steps = 1 octave
Perfect Fourth/Perfect Fifth
1
♭2
2
♭3
3
4
♭5
5
♭6
6
♭7
7
1
1→4 = 5 half-steps (Perf4)4→1 = 7 half-steps (Perf5)5+7 half-steps = 1 octave
Diminished Fifth/Augmented Fourth
1
♭2
2
♭3
3
4
♭5
5
♭6
6
♭7
7
1
1→♭5 = 6 half-step (dim5)♭5→1 = 6 half-steps (aug4)6+6 half-steps = 1 octave