cos^2(x) + cos^2(pi - x)= 1

cos^2(x) + [ cos (pi)cos (x) + sin(pi) sin(x) ] ^2

cos^2(x) + [ - cos(x) ] ^2

cos^2(x) + cos^2(x)

2cos^2(x)

This is not an identity !!!

If the question was

\(\cos^2x+\cos^2(\frac{\pi}{2}-x)=1\)

Then it's a whole nother story!

\(cos^2(x) + cos^2(\pi - x)= 1\)

\(x=\mathbb{R}\) all together!

!