Differentiate the following functions with respect to $x$ :
$(1+\cos x)^{x}$
Let $y=(1+\cos x)^{x}$
Taking log both the sides:
$\Rightarrow \log y=\log (1+\cos x)^{x}$
$\Rightarrow \log y=x \log (1+\cos x)\left\{\log x^{a}=\operatorname{alog} x\right\}$
Differentiating with respect to $\mathrm{x}$ :
$\Rightarrow \frac{\mathrm{d}(\log \mathrm{y})}{\mathrm{dx}}=\frac{\mathrm{d}[\mathrm{x} \log (1+\cos \mathrm{x})]}{\mathrm{dx}}$
$\Rightarrow \frac{d(\log y)}{d x}=x \times \frac{d[\log (1+\cos x)]}{d x}+\log (1+\cos x) \times \frac{d x}{d x}$
$\left\{\right.$ Using product rule, $\left.\frac{\mathrm{d}(\mathrm{uv})}{\mathrm{dx}}=\mathrm{u} \frac{\mathrm{dv}}{\mathrm{dx}}+\mathrm{v} \frac{\mathrm{du}}{\mathrm{dx}}\right\}$
$\Rightarrow \frac{1}{y} \frac{d y}{d x}=x \times \frac{1}{(1+\cos x)} \frac{d(1+\cos x)}{d x}+\log (1+\cos x)$
$\left\{\frac{\mathrm{d}(\log \mathrm{u})}{\mathrm{dx}}=\frac{1}{\mathrm{u}} \frac{\mathrm{du}}{\mathrm{dx}}\right\}$
$\Rightarrow \frac{1}{y} \frac{d y}{d x}=x \times \frac{1}{(1+\cos x)}(-\sin x)+\log (1+\cos x)$
$\left\{\frac{d(1+\cos x)}{d x}=\frac{d(1)}{d x}+\frac{d(\cos x)}{d x}=0+(-\sin x) \frac{d x}{d x}=-\sin x\right\}$
$\Rightarrow \frac{1}{y} \frac{d y}{d x}=\frac{-x \sin x}{1+\cos x}+\log (1+\cos x)$
$\Rightarrow \frac{d y}{d x}=y\left\{\frac{-x \sin x}{1+\cos x}+\log (1+\cos x)\right\}$
Put the value of $y=(1+\cos x)^{x}:$
$\Rightarrow \frac{d y}{d x}=(1+\cos x)^{x}\left\{\frac{-x \sin x}{1+\cos x}+\log (1+\cos x)\right\}$