#### Please solve RD Sharma Class 12 Chapter 18 Indefinite Integrals Exercise 18.23 Question 5 maths textbook solution.

Answer : $-\log \left|1-\tan \frac{x}{2}\right|+c$

Hint: To solve this question we have to convert sinx and  cosx in terms of tanx

Given:  $\int \frac{1}{1-\sin x+\cos x} d x$

Solution : $\int \frac{1}{1-\sin x+\cos x} d x$

$\left[\begin{array}{l} \sin x=\frac{2 \tan \frac{x}{2}}{1+\tan ^{2} \frac{x}{2}} \\ \cos x=\frac{1-\tan ^{2} \frac{x}{2}}{1+\tan ^{2} \frac{x}{2}} \end{array}\right]$

\begin{aligned} &I=\int \frac{1}{1-\frac{2 \tan \frac{x}{2}}{1+\tan ^{2} \frac{x}{2}}+\frac{1-\tan ^{2} \frac{x}{2}}{1+\tan ^{2} \frac{x}{2}}} d x \\ &I=\int \frac{1+\tan ^{2} \frac{x}{2}}{1+\tan ^{2} \frac{x}{2}-2 \tan \frac{x}{2}+1-\tan ^{2} \frac{x}{2}} d x \end{aligned}

\begin{aligned} &I=\int \frac{1+\tan ^{2} \frac{x}{2}}{2-2 \tan \frac{x}{2}} d x \\ &I=\int \frac{\sec ^{2} \frac{x}{2}}{2\left(1-\tan \frac{x}{2}\right)} d x \end{aligned}

\begin{aligned} &{\left[\begin{array}{l} t=\tan \frac{x}{2} \\ \frac{d t}{d x}=\frac{1}{2} \sec ^{2} \frac{x}{2} \end{array}\right]} \\ &\begin{array}{l} I=\int \frac{d t}{1-t} \\ {\left[\begin{array}{l} 1-t=u \\ -1=\frac{d u}{d t} \\ d t=-d u \end{array}\right]} \end{array} \end{aligned}

\begin{aligned} &\left.I=\int-\frac{d u}{u}=-\log |u|+c \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \quad \text { [ } \int \frac{d x}{x}=\log |x|+c\right] \\ &I=-\log |1-t|+c \\ &I=-\log \left|1-\tan \frac{x}{2}\right|+c \end{aligned}