Given a utility function of the form
U = U(X , Y , ......... )
the change in total utility as a result of small changes in the quantities of two commodities, X and Y, consumed will equal
dU = ∂U/∂X dX + ∂U/∂Y dY
Since the level of utility must be constant---that is dU = 0 ---along an indifference curve, the above equation can be rearranged to yield
0 = ∂U/∂X dX + ∂U/∂Y dY
which can be further rearranged as
dY/dX = − ∂U/∂X / ∂U/∂Y
Since
dY/dX = − Px / Py
is the slope of the budget line, we can combine the two equations immediately above to yield
Px / Py = ∂U/∂X / ∂U/∂Y .