1/cos(pi/4) is not equal to cos(-pi/4). Cos(-pi/4) is equal to cos(pi/4). It is because cos function is an even function and it produces same answer to negative and positive values. I can give you a simple reason that 0 and 2pi is same in angles and 0-pi/4 is same as 2pi-pi/4 if you see graph paper, rotate a line from positive X-axis in anti-clock wise direction it lies in fourth quadrant. Now, you see x co-ordinate is positive and hypotenuse is length so it's positive. Hence, base/hypotenuse is positive.
I hope this one helps and if any other query regarding my answer please ask.