Analytical formula for radiation trapping with partial frequency redistribution