d_a and d_p functions