How to calculate derivative of a multi-variable function, if variables are dependent of each other?

108 Views Asked by At

For a multiple variable function, such as $f(x, y)$, if $y$ is actually dependent on $x$, then I think there are two ways to calculate $df$:

  1. replace $y$ by $x$ in $f(x,y)$ and then treat the result function as a single variable function $g(x)$, then calculate $dg$
  2. calculate $df(x,y)$ using partial derivatives and then substitute.

However, I have a problem with the second method, and cannot reconcile the two.

As an example, suppose we have a function

$$f(x, y) = x + 2y + 3xy$$

but $x$ and $y$ are related via

$$y = 1 - x$$

Then the first method will give me the following

$$g(x) = f(x, 1-x) = x + 2(1-x) + 3x(1-x) = -3x^2 + 2x + 2$$ so $$dg(x) = (-6x + 2)dx$$

Using the second method, I have the following.

  1. calculate $df(x,y)$ as partial derivatives of $x$ and $y$ $$df(x, y) = f_x(x, y)dx + f_y(x,y)dy + f_{x,y}(x,y) dx dy $$ $$df(x, y) = (1+3y)dx + (2+3x)dy + 3 dx dy $$
  2. replace $y$ by $1-x$ and $dy$ by $(dy/dx)dx = -dx$ throughout $$df(x) = (1+3(1-x))dx + (2+3x)(-dx) + 3 dx(-dx) $$ $$df(x) = (-6x + 2)dx - 3 (dx)^2 $$

As you can see, there is an extra $-3(dx)^2$ term using the partial derivative method. What went wrong? I also have two questions

  1. is it legitimate to replace $dy$ by $(dy/dx)dx$ in step 2? Shouldn't term $f_ydy$ mean keeping $x$ unchanged? Then how can we replace $dy$ by $(dy/dx)dx$ as it means $x$ changes?
  2. when I substitute $y$ by $1-x$ and $dy$ by $(dy/dx)dx$, what does $df(x,y)$ become? do we write it as another function $dg(x)$ or $df(x, 1-x)$?

I'm really confused. Thank you!

1

There are 1 best solutions below

0
On

It should not contain the term of $dxdy$.

It should be the following instead:

$$df(x,y)=f_x(x,y)dx+f_y(x,y)dy$$

and $dy=-1 dx$.

Then you can write $df(x)=...dx$

q1. Yes, you can write $dy$ as $dy/dx dx$ as long as now you are trying to find $dx$. So similarly, although $f_y dy$ means keeping $x$ unchanged when you do $df(x,y)$, but $dy$ will involve change of $x$ when you look for $df(x)$. This could be considered as chain rule.

q2. That's why I suggest you start a new line writing $df(x)=...$ when you start to replace $dy$ by $\frac{dy}{dx} dx$.