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)`

Hope this helps to understand better

Given to solve

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

For convenience, let `theta = x`

=>

`int 1/(cosx - 1) dx`

let `u = tan(x/2) => dx = (2/(1+u^2)) du`

so ,

`cos(x) = (1-u^2)/(1+u^2)` (See my reply below for an explanation)

so,

`int 1/(cos(x) - 1) dx`

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

= `int 1/(((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 (2)/(((1-u^2)-(1+u^2)) ) du`

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

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

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

= `-[u^(-2+1)/(-2+1)]`

= `u^-1`

= `1/u`

= `1/tan(x/2) `

= `cot(x/2)+c`

But `x= theta`

so,

`int 1/(cos(theta) - 1) d theta = cot(theta/2)+c`