Given to solve ,

`int cos(theta) / (1+cos(theta)) d theta`

just for easy solving let `x=theta `

so the equation is given as

`int cos(x) / (1+cos(x)) d x ` -------(1)

let `u= tan(x/2)` ,=> then `cos(x)` is given as

=> `cos(x) = (1-tan^2(x/2))/(1+tan^2(x/2)) = (1-u^2)/(1+u^2)`

=>`cos(x)= (1-u^2)/(1+u^2)`

so `dx = 2/(1+u^2) du`

the expalnation is given below after this solution at NOTE.

so ,on substituting the value of u in the function (1) , we get

`int cos(x) / (1+cos(x)) d x`

=`int ( (1-u^2)/(1+u^2)) / ( (1-u^2)/(1+u^2) +1) 2/(1+u^2) du`

=`int ( (1-u^2)/(1+u^2)) / ( (1-u^2+1+u^2)/(1+u^2) ) 2/(1+u^2) du`

=`int ( (1-u^2) / ( (1-u^2+1+u^2) ) 2/(1+u^2) du`

=`int ( (1-u^2) / ( (2) )) 2/(1+u^2) du`

=`int ( (1-u^2)/(1+u^2) du`

=`int ( (2-1-u^2)/(1+u^2) du`

=`int ((2)/(1+u^2)) -1 du`

=`int ((2)/(1+u^2)) du -int 1 du`

=`2int ((1)/(1+u^2)) du -u`

as we know `int ((1)/(1+u^2)) du = tan^(-1) u`

so,

`2int ((1)/(1+u^2)) du -u`

=`2 tan^(-1) u - u`

but `u= tan(x/2)` ,so

= `2tan^(-1) (tan(x/2)) - tan(x/2) +c`

=` 2(x/2) - tan(x/2) +c`

but` x= theta` ,so

= `2(theta/2) - tan(theta/2) +c`

=`theta - tan(theta/2) +c` **is the final answer**

NOTE:

Explanation for `cos(x) = (1-u^2)/(1+u^2)`

before that , we know

`cos(2x)= cos^2(x) -sin^2(x)`

as `cos^2(x)` can be written as `1/(sec^2(x))`

and we can show `sin^2(x) = ((sin^2(x))/(cos^2(x) ))/(1/(cos^2(x)))`

= `tan^2(x)/sec^2x`

so now ,

`cos(2x)= cos^2(x) -sin^2(x)`

= `(1/sec^2(x)) - (tan^2(x)/sec^2(x))`

=`(1-tan^2(x))/(sec^2(x))`

but `sec^2(x) = 1+tan^2(x)` ,as its an identity

so,

=`(1-tan^2(x))/(sec^2(x))`

=`(1-tan^2(x))/(1+(tan^2(x)))`

so ,

`cos(2x) = (1-tan^2(x))/(1+(tan^2(x)))`

so,

then

`cos(x) = (1-tan^2(x/2))/(1+(tan^2(x/2)))`

as before we told to assume that `u= tan(x/2),`

so,

`cos(x) = (1-u^2)/(1+u^2)`