D_nominal, D_min, and D_max represent the most likely, minimum, and maximum (well technically not maximum, just 3 standard deviations from most likely, of which 99.7% of trajectories will fall within) distance 2024 YR4 will pass from the center of the Moon (NOT the surface). They're taken from the linked NASA website. R_moon is the radius of the Moon.
L_impact is length of the impact corridor (the line where 2024 YR4 could impact the Moon). Since it doesn't pass through the center of the Moon, it's not simply 2*R_moon and so we need a simple formula to calculate it from R_moon and D_min.
P(x) is a probability density function; it's the black curve you can see. It shows, for a given trajectory along the line of possible trajectories, how likely 2024 YR4 is to follow that trajectory. It's shifted a bit from the center since the most likely trajectories are not exactly centered on the Moon. P_impact is the area of P(x) that falls within +/- L_impact, AKA the probability that the trajectory will intersect the Moon, AKA the impact probability.
The rest is just some graphing stuff that doesn't matter to the calculation.