# chain rule with manual substitution

Given that I have this function that I want to differentiate.

$$f(x) = \frac{\cos(x) \sin(x)}{2x+1}$$

I know that I can do this with quotient and product rule, but I would like to understand chain rule fully on this one.

So I say $z(x) = \cos(x) \sin(x)$ and alter my original problem:

$$h(x) = \frac{z(x)}{2x+1}$$

Now, would I still do $\frac{\mathrm d}{\mathrm dx}$ or $\frac{\mathrm d}{\mathrm dz(x)}$?

If I do the latter, I will get:

$$\frac{\mathrm d}{\mathrm dz(x)} h(x) = \frac{\mathrm d}{\mathrm dz(x)}\frac{z(x)}{2x+1} = \frac{1}{2x-1}$$

If I replace $z(x)$ with what I had before, I will not get the right result at all, I will just get the $f(x)$ back.

Then I tried to apply chain rule, like this:

$$\frac{\mathrm d}{\mathrm dz(x)} h(x) = \frac{\mathrm d}{\mathrm dz(x)} \frac{z(x)}{2x+1} \frac{\mathrm d}{\mathrm dx} z(x) = \frac{\cos(x)^2- \sin(x)^2}{2x-1}$$

Which is not correct either, since the $\cos(x) \sin(x)$ term is missing.

Differentiating against plain $x$:

$$\frac{\mathrm d}{\mathrm dx} h(x) = \frac{\mathrm d}{\mathrm dx} \frac{z(x)}{2x+1} = \frac{z'(x)(2x-1)-2z(x)}{2x-1}$$

Now I did not use the chain rule to get the right result. If I slap another $z'(x)$ on there, as the inner derivative, I get too much.

So how would I use the chain rule the right way in this problem?

-
The given function is not a composition (other than the trivial ones). You don't use the chain rule... –  David Mitra Nov 19 '11 at 17:25
The chain rule is for compositions of functions. If you can't write your original function as a composition, then you can't apply the chain rule. Which functions can you compose to give your original function? –  Guess who it is. Nov 19 '11 at 17:27
I do not really see any good function that I could compose the original out of. So I guess I just use no chain rule, since one has to use quotient and product rule anyway. –  queueoverflow Nov 19 '11 at 22:12

My apologies if this is somewhat off point:

Consider the two functions: $$f(x) = \sin\bigl((\cos x)\bigr),\qquad {\rm and}\qquad g(x)=\cos (x) \sin (x)$$

Are they the same?

Well... How would you compute $f(\pi/4)$, say?

Let's do it: formally substituting: $$f(\pi/4) = \sin\bigl(\cos(\pi/4)\bigr).$$ To simplify this, note that you have to compute $\cos(\pi/4)$ first (you take cosine of something). $\cos(\pi/4)=\sqrt2/2$, so going back to $f$: $$f(\pi/4) = \sin\bigl(\cos(\pi/4)\bigr)= \sin(\sqrt2/2)\approx 0.65\,.$$

How would you compute $g(\pi/4)$? Let's do it: formally substituting: $$g(\pi/4) = \cos(\pi/4) \sin(\pi/4).$$ Here, the first thing we have to do is compute the cosine of $\pi/4$ and the sine of $\pi/4$. We obtain $$g(\pi/4) = \cos(\pi/4) \sin(\pi/4) =(\sqrt2/2)\cdot(\sqrt2/2)=1/2.$$

$f$ is a composition of functions; it's a "function of a function". That is, there is an "outer function" ($\sin$ in this case) that is evaluated at the inner function's ($\cos$ in this case) value. You use the chain rule to find the derivative of a composition: $$\Bigl[ f\bigr(g(x)\bigr)\Bigr]' = f'\bigr(g(x)\bigr)\cdot g'(x).$$

$g$ is a product of two functions. For this, you of course use the product rule: $$\bigl[ f(x)g(x)\bigr]' =f'(x)g(x)+f(x)g'(x).$$

When differentiating a complicated function, the first thing you should do is determine what type it is at the "outermost level" and use the appropriate rule.

-
Thanks for your detailed answer. It answers the question to the point "No chain rule needed". –  queueoverflow Nov 19 '11 at 22:06

After doing some more digging, I finally came up with a way to do this with the chain rule. The point is, that my function $f$ does not solely depend on $z$ but also on $x$, yielding $f(x, z)$. If I use multivariable calculus on this one, I do get the right result.

$$z(x) = \cos(x) \sin(x)$$

$$\frac{\mathrm d}{\mathrm dx}f(x,z) = \frac{\partial}{\partial x} f(x, z) + \frac{\partial}{\partial z} f(x, z) \cdot \frac{\partial}{\partial x} z$$

Now here comes up the chain rule.

Plugging the concrete functions in:

$$\frac{\mathrm d}{\mathrm dx} \frac{z}{2x+1} = \frac{\partial}{\partial x} \frac{z}{2x+1} + \frac{\partial}{\partial z} \frac{z}{2x+1} \cdot \frac{\partial}{\partial x} \cos(x) \sin(x)$$

Now doing the actual deriving:

$$\frac{\mathrm d}{\mathrm dx} \frac{z}{2x+1} = \frac{-2z}{(2x+1)^2} + \frac{1}{2x+1} \cdot (\cos(x)^2 \sin(x)^2)$$

Bringing it onto one fraction:

$$\frac{\mathrm d}{\mathrm dx} \frac{z}{2x+1} = \frac{-2z + (2x+1)(\cos(x)^2 \sin(x)^2)}{(2x+1)^2}$$

Simplify:

$$\frac{\mathrm d}{\mathrm dx} \frac{z}{2x+1} = \frac{(2x+1)(\cos(x)^2 \sin(x)^2) - 2z}{(2x+1)^2}$$

Plugging in $z$:

$$\frac{\mathrm d}{\mathrm dx} \frac{\cos(x) \sin(x)}{2x+1} = \frac{(2x+1)(\cos(x)^2 \sin(x)^2) - 2\cos(x) \sin(x)}{(2x+1)^2}$$

Now this yields the same result as the regular method. I do see that 12 grade math against second semester university math is not really efficient, but I think I now got the whole concept.

-
You could have made things slightly easier for yourself by noting that $\sin\,2x=2\sin\,x\cos\,x$... –  Guess who it is. Nov 20 '11 at 0:11
That sounds good. I really need to brush up on trig … –  queueoverflow Nov 20 '11 at 13:20