# What are the first and second derivatives of  g(x) =ln(tanx)-tan(lnx)?

Feb 28, 2018

$g ' \left(x\right) = \cot \left(x\right) + \tan \left(x\right) - \frac{{\sec}^{2} \left(\ln \left(x\right)\right)}{x}$
$g ' ' \left(x\right) = {\sec}^{2} \left(x\right) - {\csc}^{2} \left(x\right) - \frac{2 {\sec}^{2} \left(\ln x\right) \tan \left(\ln x\right) - {\sec}^{2} \left(\ln x\right)}{x} ^ 2$

#### Explanation:

Recall that $\frac{d}{\mathrm{dx}} \ln \left(x\right) = \frac{1}{x}$

Furthermore, if we have a natural logarithm whose argument is another function, $\ln \left(f \left(x\right)\right) ,$ we can say

$\frac{d}{\mathrm{dx}} \ln \left(f \left(x\right)\right) = \frac{1}{f} \left(x\right) \cdot \frac{d}{\mathrm{dx}} f \left(x\right)$ As per the Chain Rule.

Let's take a look at $\ln \left(\tan \left(x\right)\right) :$

$\frac{d}{\mathrm{dx}} \ln \left(\tan \left(x\right)\right) = \frac{1}{\tan} \left(x\right) \cdot \frac{d}{\mathrm{dx}} \tan \left(x\right)$

$\frac{d}{\mathrm{dx}} \ln \left(\tan \left(x\right)\right) = {\sec}^{2} \frac{x}{\tan} \left(x\right)$

Let's simplify this a bit, using the fact that ${\sec}^{2} \left(x\right) = 1 + {\tan}^{2} \left(x\right)$:

$\frac{d}{\mathrm{dx}} \ln \left(\tan \left(x\right)\right) = \frac{1 + {\tan}^{2} \left(x\right)}{\tan} \left(x\right) = \frac{1}{\tan} \left(x\right) + \frac{{\tan}^{\cancel{2} 1} \left(x\right)}{\cancel{\tan}} \left(x\right) = \frac{1}{\tan} \left(x\right) + \tan \left(x\right) = \cot \left(x\right) + \tan \left(x\right)$

Recall that $\frac{d}{\mathrm{dx}} \tan \left(x\right) = {\sec}^{2} \left(x\right)$.

If we have a tangent function whose argument is another function, $\tan \left(f \left(x\right)\right) ,$ we can say

$\frac{d}{\mathrm{dx}} \tan \left(f \left(x\right)\right) = {\sec}^{2} \left(f \left(x\right)\right) \cdot \frac{d}{\mathrm{dx}} f \left(x\right)$ As per the Chain Rule.

Looking at $\tan \left(\ln \left(x\right)\right) :$

$\frac{d}{\mathrm{dx}} \tan \left(\ln \left(x\right)\right) = {\sec}^{2} \left(\ln \left(x\right)\right) \cdot \frac{1}{x} = {\sec}^{2} \frac{\ln \left(x\right)}{x}$

Combining our two derivatives together, we get

g'(x)=d/dx(ln(tan(x))-tan(ln(x))

$g ' \left(x\right) = \frac{d}{\mathrm{dx}} \ln \left(\tan \left(x\right)\right) - \frac{d}{\mathrm{dx}} \tan \left(\ln \left(x\right)\right)$

$g ' \left(x\right) = \cot \left(x\right) + \tan \left(x\right) - \frac{{\sec}^{2} \left(\ln \left(x\right)\right)}{x}$

For $g ' ' \left(x\right) :$

$\frac{d}{\mathrm{dx}} \cot \left(x\right) = - {\csc}^{2} \left(x\right)$
$\frac{d}{\mathrm{dx}} \left(\tan \left(x\right)\right) = {\sec}^{2} \left(x\right)$

$\frac{d}{\mathrm{dx}} \frac{{\sec}^{2} \left(\ln \left(x\right)\right)}{x} = \frac{x \frac{d}{\mathrm{dx}} {\sec}^{2} \left(\ln \left(x\right)\right) - {\sec}^{2} \ln \left(x\right) \frac{d}{\mathrm{dx}} x}{x} ^ 2$

This gives us:

$\frac{\frac{2 \cancel{x} 2 \sec \left(\ln x\right) \sec \left(\ln x\right) \tan \left(\ln x\right)}{\cancel{x}} - {\sec}^{2} \left(\ln x\right)}{x} ^ 2$

$\frac{{\sec}^{2} \left(\ln x\right) \tan \left(\ln x\right) - {\sec}^{2} \left(\ln x\right)}{x} ^ 2$

$g ' ' \left(x\right) = {\sec}^{2} \left(x\right) - {\csc}^{2} \left(x\right) - \frac{2 {\sec}^{2} \left(\ln x\right) \tan \left(\ln x\right) - {\sec}^{2} \left(\ln x\right)}{x} ^ 2$