apostol calculus, trouble simplifying integral
i'm reading apostol's calculus book vol.1 and for those of you who have it i am having trouble on page 265, where he does the integral of 1 / (sinx + cosx) using a wierstrauss substitution. i understand the substitutions he made and the answer he got which was (sqrt(2) / 2) log[(tan(x/2) - 1 + sqrt(2)) / (tan(x/2) - 1 - sqrt(2))] + C. next he tries to simplify it by saying sqrt(2) - 1 = tan(pi/8). so the numerator can be simplified to tan(x/2) + tan(pi/8). i know he is going to use tan(a+b) = (tana + tanb) / (1 - tana tanb) to simplify so he wants the denominator to be in the form 1 - (tan a)(tan b).
however, i am having trouble following his steps to get the denominator to that form. he does this in the book: | tan(x/2) - 1 - sqrt(2) | = (sqrt2 + 1)(sqrt2 - 1)tan(x/2) - 1 = (sqrt2 + 1) (1 - tan(x/2)tan(pi/8).
i have no idea how he got from the original denominator which was tan(x/2) - 1 - sqrt(2) to (sqrt2 + 1)(sqrt2 - 1)tan(x/2) - 1. i expanded out the 2nd term in the equality but it did not match the 1st term in the equality. i am also confused on notation. on the first equality is that an absolute value sign? going from the first term to the second term | tan(x/2) - 1 - sqrt(2) | = (sqrt2 + 1)(sqrt2 - 1)tan(x/2) - 1 has really got me confused. please help.