# How do you differentiate f(x) = [cot(x) + csc(x)]/[tan(x) - sin(x)]?

Feb 24, 2016

$f ' \left(x\right) = \frac{- \sin x \left({\sin}^{2} \left(\frac{x}{2}\right) + \cos x\right)}{4 {\sin}^{6} \left(\frac{x}{2}\right)}$

#### Explanation:

First simplify $f \left(x\right)$.

$f \left(x\right) = \frac{\cot x + \csc x}{\tan x - \sin x}$

$= \frac{\cos \frac{x}{\sin} x + \frac{1}{\sin} x}{\sin \frac{x}{\cos} x - \sin x}$

$= \frac{\frac{1}{\sin} x \left(\cos x + 1\right)}{\sin \frac{x}{\cos} x \left(1 - \cos x\right)}$

$= \frac{\cos x}{{\sin}^{2} x} \cdot \frac{\left(1 + \cos x\right)}{\left(1 - \cos x\right)}$

$= \frac{\cos x}{{\sin}^{2} x} \cdot \frac{\left(1 + \cos x\right)}{\left(1 - \cos x\right)} \cdot \frac{\left(1 - \cos x\right)}{\left(1 - \cos x\right)}$

$= \frac{\cos x}{{\sin}^{2} x} \cdot \frac{1 - {\cos}^{2} x}{{\left(1 - \cos x\right)}^{2}}$

$= \frac{\cos x}{{\sin}^{2} x} \cdot \frac{{\sin}^{2} x}{{\left(1 - \cos x\right)}^{2}}$

$= \frac{\cos x}{{\left(1 - \cos x\right)}^{2}}$

$= \frac{\cos x}{{\left(2 {\sin}^{2} \left(\frac{x}{2}\right)\right)}^{2}}$

$= \frac{\cos x}{4 {\sin}^{4} \left(\frac{x}{2}\right)}$

Now we use the quotient rule to find the derivative of $f$.

$f ' \left(x\right) = \frac{\text{d"}{"d} x}{\frac{\cos x}{4 {\sin}^{4} \left(\frac{x}{2}\right)}}$

$= \frac{\left(4 {\sin}^{4} \left(\frac{x}{2}\right)\right) \frac{\text{d"}{"d"x}(cosx) - (cosx)frac{"d"}{"d} x}{4 {\sin}^{4} \left(\frac{x}{2}\right)}}{{\left(4 {\sin}^{4} \left(\frac{x}{2}\right)\right)}^{2}}$

$= \frac{\left(4 {\sin}^{4} \left(\frac{x}{2}\right)\right) \left(- \sin x\right) - \left(\cos x\right) \left(8 {\sin}^{3} \left(\frac{x}{2}\right) \cos \left(\frac{x}{2}\right)\right)}{16 {\sin}^{8} \left(\frac{x}{2}\right)}$

$= - \frac{{\sin}^{2} \left(\frac{x}{2}\right) \sin x + \cos x \left(2 \cos \left(\frac{x}{2}\right) \sin \left(\frac{x}{2}\right)\right)}{4 {\sin}^{6} \left(\frac{x}{2}\right)}$

$= - \frac{{\sin}^{2} \left(\frac{x}{2}\right) \sin x + \cos x \sin x}{4 {\sin}^{6} \left(\frac{x}{2}\right)}$

$= \frac{- \sin x \left({\sin}^{2} \left(\frac{x}{2}\right) + \cos x\right)}{4 {\sin}^{6} \left(\frac{x}{2}\right)}$