Q:

Derivative of product of three functions: product rule

I am trying to find the derivative of $f(x)= xe^x \csc x$, and I am not too sure how to even start. 
Is it two terms or three? $xe^x$ and $\csc x$ or is it $x$, $e^x$ and $\csc x$? I can't get a proper answer either way. 
With two terms I get $xe^x(-\csc x\cot x) + \csc x(e^x)$.

A:

To find the derivative of $(abc)'$ you use repeated application of the product rule:
$$
(abc)' = (ab)'c+abc' = (ab'+a'b)c+abc' = a'bc+ab'c+abc'.
$$
In your case $a(x) = x$, $b(x) = \mathrm e^x$ and $c(x) = \operatorname{csc}(x)$, so
$$
a' = 1, b' = \mathrm e^x \text{ and }c' = -\cot x\csc x.
$$
To make it more clear: in $x \mathrm e^x\csc x$ you have three function rather than two, but $x\mathrm e^x$ is also a product of two functions, so
$$
(x\mathrm e^x\csc x)' = (x\mathrm e^x)'\csc x+x\mathrm e^x(\csc x)'.
$$
We can calculate the latter term, but what about $(x\mathrm e^x)'$? You again apply the product rule: 
$$
(x\mathrm e^x)' = x'\mathrm e^x+x(\mathrm e^x)'.
$$

A:

As J.M. said,
one easy way yo handle
arbitrary products and quotients
is to use the
logarithmic derivative:
$(\ln f(x))'
=\dfrac{f'(x)}{f(x)}
$.
Suppose $f(x)$
contains a mixture of
products and quotients:
$f(x)
=\dfrac{a_1(x)a_2(x) ... a_m(x)}{b_1(x)b_2(x)...b_n(x)}
=\dfrac{\prod_{i=1}^m a_i(x)}{\prod_{j=1}^n b_j(x)}
$.
Taking the log,
$\ln f(x)
=\sum_{i=1}^m \ln a_i(x)-\sum_{j=1}^n \ln b_j(x)
$.
Differentiating both sides,
$\begin{array}\\
\dfrac{f'(x)}{f(x)}
&=(\ln f(x))'\\
&=(\sum_{i=1}^m \ln a_i(x)-\sum_{j=1}^n \ln b_j(x))'\\
&=\sum_{i=1}^m (\ln a_i(x))'-\sum_{j=1}^n (\ln b_j(x))'\\
&=\sum_{i=1}^m \dfrac{a_i'(x)}{a_i(x)}-\sum_{j=1}^n \dfrac{b_j'(x)}{b_j(x)}\\
\end{array}
$.
Therefore
$\begin{array}\\
f'(x)
&=f(x)\left(\sum_{i=1}^m \dfrac{a_i'(x)}{a_i(x)}-\sum_{j=1}^n \dfrac{b_j'(x)}{b_j(x)}\right)\\
&=\dfrac{\prod_{i=1}^m a_i(x)}{\prod_{j=1}^n b_j(x)}\left(\sum_{i=1}^m \dfrac{a_i'(x)}{a_i(x)}-\sum_{j=1}^n \dfrac{b_j'(x)}{b_j(x)}\right)\\
\end{array}
$.
Here are the two most common cases:
$f(x) = a_1(x) a_2(x)$ - the product with $m=2$ and $n=0$.
$f'(x)
=a_1(x) a_2(x)\left(\dfrac{a_1'(x)}{a_1(x)}+\dfrac{a_2'(x)}{a_2(x)}\right)
=a_1'(x) a_2(x)+a_1(x) a_2'(x)
$.
$f(x) = \dfrac{a(x)}{b(x)}$ - the quotient
with $m=n=1$.
$f'(x)
= \dfrac{a(x)}{b(x)}\left(\dfrac{a'(x)}{a(x)}-\dfrac{b'(x)}{b(x)}\right)
= \dfrac{a'(x)}{b(x)}-\dfrac{a(x)b'(x)}{b^2(x)}
= \dfrac{a'(x)b(x)-a(x)b'(x)}{b^2(x)}
$.
Finally, your case - 
the product of three functions:
$\begin{array}\\
f(x)
&=a(x)b(x)c(x)\left(\dfrac{a'(x)}{a(x)}+\dfrac{b'(x)}{b(x)}+\dfrac{c'(x)}{c(x)}\right)\\
&=a'(x)b(x)c(x)+a(x)b'(x)c(x)+a(x)b(x)c'(x)\\
\end{array}
$

