I don’t understand how the partial derivative of J with respect to d is 2. Shouldn’t it be d? Or am I missing something completely. thanks.

The partial derivative wrt d of (1/2)d^2 is indeed d but the value of d in the specific example happens to be two. I suspect they just plugged in 2 for d. It’s not written clearly.