# Differentiate the function with respect to x.

Question:

Differentiate the function with respect to x.

$x^{x \cos x}+\frac{x^{2}+1}{x^{2}-1}$

Solution:

Let $y=x^{x \cos x}+\frac{x^{2}+1}{x^{2}-1}$

Also, let $u=x^{x \cos x}$ and $v=\frac{x^{2}+1}{x^{2}-1}$

$\therefore y=u+v$

$\Rightarrow \frac{d y}{d x}=\frac{d u}{d x}+\frac{d v}{d x}$   ...(1)

$u=x^{x \cos x}$

$\Rightarrow \log u=\log \left(x^{x \cos x}\right)$

$\Rightarrow \log u=x \cos x \log x$

Differentiating both sides with respect to x, we obtain

$\frac{1}{u} \frac{d u}{d x}=\frac{d}{d x}(x) \cdot \cos x \cdot \log x+x \cdot \frac{d}{d x}(\cos x) \cdot \log x+x \cos x \cdot \frac{d}{d x}(\log x)$]\

$\Rightarrow \frac{d u}{d x}=u\left[1 \cdot \cos x \cdot \log x+x \cdot(-\sin x) \log x+x \cos x \cdot \frac{1}{x}\right]$

$\Rightarrow \frac{d u}{d x}=x^{x \cos x}(\cos x \log x-x \sin x \log x+\cos x)$

$\Rightarrow \frac{d u}{d x}=x^{x \cos x}[\cos x(1+\log x)-x \sin x \log x]$   ...(2)

$v=\frac{x^{2}+1}{x^{2}-1}$\

$\Rightarrow \log v=\log \left(x^{2}+1\right)-\log \left(x^{2}-1\right)$

Differentiating both sides with respect to x, we obtain

$\frac{1}{v} \frac{d v}{d x}=\frac{2 x}{x^{2}+1}-\frac{2 x}{x^{2}-1}$

$\Rightarrow \frac{d v}{d x}=v\left[\frac{2 x\left(x^{2}-1\right)-2 x\left(x^{2}+1\right)}{\left(x^{2}+1\right)\left(x^{2}-1\right)}\right]$

$\Rightarrow \frac{d v}{d x}=\frac{x^{2}+1}{x^{2}-1} \times\left[\frac{-4 x}{\left(x^{2}+1\right)\left(x^{2}-1\right)}\right]$

$\Rightarrow \frac{d v}{d x}=\frac{-4 x}{\left(x^{2}-1\right)^{2}}$   ...(3)

From (1), (2), and (3), we obtain

$\frac{d y}{d x}=x^{x \cos x}[\cos x(1+\log x)-x \sin x \log x]-\frac{4 x}{\left(x^{2}-1\right)^{2}}$