Partial derivatives of functions with implicit variables

58 Views Asked by At

Consider a function $f(x,y)$ with $x$ being a function of $y$, that is $f(x(y), y)$. I would like to compute the gradient of this function $\nabla f = (\partial_x f, \partial_y f)$. Using the change of derivative formula, $$\frac{\partial}{\partial x} = \frac{\partial y}{\partial x}\frac{\partial}{\partial y}.$$ If we apply this partial derivative to the function $f$, we find $$\frac{\partial}{\partial x}f(x(y),y) = \frac{\partial y}{\partial x}\frac{\partial}{\partial y} f(x(y),y) = \frac{\partial y}{\partial x} \left[\frac{\partial f}{\partial x}\frac{\partial x}{\partial y} + \frac{\partial f}{\partial y} \right] = \frac{\partial f}{\partial x} + \frac{\partial y}{\partial x} \frac{\partial f}{\partial y}, $$ which gives an extra term $\frac{\partial y}{\partial x} \frac{\partial f}{\partial y}$ in addition to $\frac{\partial f}{\partial x}$. Why is there this extra term? Since $x$ is really a function of $y$, is the gradient $$ \nabla f = (\partial_x f, \partial_y f) $$ or $$\nabla f = (\frac{\partial y}{\partial x} \frac{\partial f}{\partial y} + \frac{\partial f}{\partial x}, \frac{\partial f}{\partial y})$$ or even $$\nabla f = (\frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}+\frac{\partial f}{\partial x}\frac{\partial x}{\partial y} ) ?$$

Any help is appreciated.

2

There are 2 best solutions below

1
On

Let $f:\mathbb R^2\to \mathbb R$ and $g:\mathbb R \to \mathbb R^2$ is given by $g(y) = (h(y),y)$ for some function $h:\mathbb R \to \mathbb R$. Then our goal is to compute the derivative of $f\circ g$. By the chain rule, it is $$f'(g(y))g'(y) = \partial_1 f(g(y))h'(y)+\partial_2f(g(y))$$ , where $$\partial_1 f(g(y)) = \lim_{h\to 0}\frac{f(g(y)+he_1)-f(g(y))}{h}$$ and similarly for $\partial_2 f(g(y))$.

0
On

The above answer was posted while I was working on it so I don't have another solution but a few comments around it (too long for actual comment).

Starting with $z=f(x,y)$ and $x=h(y)$ you can just view this as $z=k(y)$ and then calculate $\frac{dz}{dy}=k'(y)$ directly; which will agree with the formula provided in the solution.

For example if $f(x,y)=x^2y$ and $x=h(y)=y^3$ then $k(y)=y^7$ and $k'(y)=7y^6$

Or using the RHS of the above solution we would get:

$k'(y) = \nabla f\cdot g'(y) = \langle\frac{\partial f}{\partial x} ,\frac{\partial f}{\partial y}\rangle\cdot\langle h'(y),1\rangle$

$=\langle 2xy,x^2\rangle\cdot\langle3y^2,1\rangle = (2y^4)(3y^2)+y^6=7y^6$

which shows the actual gradient a little more explicitly.

Finally, this is a special case of the following standard chain rule application:

If $z=f(x,y)$ and $x=u(t), y=v(t)$ then:

$\frac{dz}{dt} = \frac{\partial f}{\partial x}\frac{dx}{dt}+\frac{\partial f}{\partial y}\frac{dy}{dt}$

Setting $x=h(y)$ and $y=t$ yields the original solution and matches the second component in the last gradient in the original post (so correct, just should have been a stand-alone derivative of a function of a single variable not part of a gradient). This further supports the improved notation in the original solution.