A current of $18$ amperes branches into currents $x$, $y$, and $z$ through resistors with resistances $5$, $7$, and $4$ ohms as shown.
It is known that the current splits in such a way that the sum of the currents through the three resistors equals the initial current.(Kirchhoff Law). The energy generated in each resistor is given by $E=I^2R$, where $I$ is the current in that resistor and $R$ is the resistance. Use Lagrange multipliers to find the currents $x$, $y$, and $z$ which will minimize the total energy generated. (It turns out that nature always splits the currents so that the total energy is minimized.)
Since $E=I^2 R$, the total energy should be
$$E=x^2 R_1+y^2 R_2 +z^2 R_3$$
where $x,y,z$ are the currents through each resistors. This is the function you want to minimize. Can you continue from here?