I've read in a paper by Tevian Dray an alternative way to solve optimization problems manipulating "differentials". Here is an example of how it works (next I quote the paper).
Consider the problem of minimizing the length of a piecewise straight path connecting two fixed points with a given line, as shown in Figure 1. For instance, the line could represent a river along which a single pumping station is to be built to serve two towns. The distances $C$, $D$, and $S = a + b$ are specified; the goal is to determine $a$ and/or $b$ so that $ℓ = p + q$ is minimized.
The standard solution to this problem involves expressing $a, b, p, q$, and hence $ℓ$, in terms of a single variable, typically $a$, then minimizing $ℓ$ by computing $\frac {dℓ} {da}$ and setting it equal to zero. This computation is straightforward, but involves the derivatives of square roots and some messy algebra.
Consider instead the following solution, using differentials. First, write down what you know: $$a + b = S$$ $$a^2 + C^2 = p^2$$ $$b^2 + D^2 = q^2$$ $$p + q = ℓ$$
where $S, C, D$ are known constants. Next, take the differential of each equation: $$da + db = 0$$ $$2a\ da = 2p\ dp$$ $$2b\ db = 2q\ dq$$ $$dp + dq = dℓ$$
We are trying to minimize $ℓ$, so we set $dℓ = 0$ to obtain
$$0 = dℓ = dp + dq = \frac{a}{p} da + \frac{b}{q} db = \left ( \frac{a}{p} - \frac{b}{q} \right ) da $$
so that
$$\frac{b^2}{a^2}=\frac{q^2}{p^2}=\frac{b^2+D^2}{a^2+C^2}$$
which (since lengths must be positive) quickly yields
$$\frac{b}{a}=\frac{D}{C}$$
so that
$$a =\frac{CS}{C + D}$$ $$b =\frac{DS}{C + D}$$ and it is straightforward to verify that these values do in fact minimize $ℓ$.
I've tried to use this method to solve some problems, and sometimes it works and sometimes doesn't (when I have to optimize a function $f(x,y,z)$ with two constraint function $g_1(x,y,z)=c_1$ and $g_2(x,y,z)=c_2$, generally I have to use Lagrange multipliers because this manipulation of differentials doesn't lead to the correct answer). Also, I've seen this method been used in some thermodynamics textbooks.
So, my questions are why this manipulation of differentials is capable to solve optimization problems? When this leads to a wrong answer? Where (a book, video, etc.) can I learn more about this method? (to use it systematically)
Note: I've also asked this question on Mathematics Stack Exchange
