[ I posted the question on Math StackExchange but didn't get any reply nor comment, so I'm trying here ]

I am learning about mass transportation theory and the Monge-Ampere equation, to transport a function $f$ toward $g$ by a change of variable $T$. In particular, in order to solve for : $$ \min \int c(x, T(x)) f(x) dx $$ under the constraint $ f = g\circ T~(\det(DT))$ where $\det(DT)$ is the jacobian of T (here, the determinant is supposed to be positive to remove absolute values), and $c(x,y)$ is a cost function, I found in a lecture that one introduces Lagrange multipliers $\lambda = \lambda(x)$ and solve for the extended functional:

$$ \min \int \left[ c(., T) f + \lambda~ g\circ T (\det DT) \right] $$ By computing the Euler Lagrange equation of the above equation, one get : $$ f~c_{yi} = D_i[\lambda g~(cof~DT)^{i,j}] -\lambda~(\det DT) g_{yi} $$ where $cof DT$ stands for the matrix of cofactors for the jacobian matrix $DT$.

I have a few basic questions, that I'd like to be answered assuming very little knowledge on my side :

- Why would the lagrange multipliers depend on $x$ ? Usually, when I have a set of equations to minimize with a set of equations as constraints, I have one $\lambda$ per constraint, and it doesn't depend on $x$

- I don't understand at all how one arrives to this Euler Lagrange equation. I mean, I know that in general, deriving a determinant with respect to a matrix gives a cofactor matrix... but nothing more that I can use here. Could someone add 5-6 steps in between ? what are those $y_i$ and $i,j$ indices ?? Please, treat me as a newbie :)

Thank you very much in advance !