What is the difference between pixel pitch and pixel density?

It’s just a reciprocal relationship. Where pixel density measures, say, the number of pixels per inch, pixel pitch measures the number of inches per pixel (or the center-to-center spacing between pixels).

Pixel pitch expressed as a linear measurement, and if the pixels are non-square you may see two values specified. Pixel density, on the other hand, may be expressed as a linear measurement (pixels per inch or millimeter or what have you) or as an area measurement (pixels per square inch or pixels per square millimeter) — your equation assumes an area measure of pixel density and square pixels, and converts to a linear value.

I should probably add that pixel pitch is usually used to state device specifications (screens or sensors) — you wouldn’t often see it used to describe, say, the resolution settings you used to print an image.