Step 1: Given,
\[
\tan^2x=1
\]
Step 2: Taking square root:
\[
\tan x=\pm 1
\]
Step 3: We know:
\[
\tan\frac{\pi}{4}=1
\]
and
\[
\tan\left(-\frac{\pi}{4}\right)=-1
\]
Step 4: Since \(\tan x\) has period \(\pi\), the general solution is:
\[
x=n\pi\pm\frac{\pi}{4}
\]
\[
\boxed{n\pi\pm\frac{\pi}{4}}
\]