Fixed derivatives with respect to p

Signed-off-by: David Evans <dgevans42@gmail.com>