\(\left(ab-1\right)^2+\left(a+b\right)^2=a^2b^2-2ab+1+a^2+2ab+b^2=a^2+b^2+a^2b^2+1=a^2\left(b^2+1\right)+\left(b^2+1\right)=\left(a^2+1\right)\left(b^2+1\right)\)
\(\left(ab-1\right)^2+\left(a+b\right)^2=a^2b^2-2ab+1+a^2+2ab+b^2=a^2b^2+a^2+b^2+1=\left(a^2b^2+a^2\right)+\left(b^2+1\right)=a^2\left(b^2+1\right)+\left(b^2+1\right)=\left(a^2+1\right)\left(b^2+1\right)\)
\(\left(ab-1\right)^2+\left(a+b\right)^2\)
\(=a^2b^2+1+a^2+b^2\)
\(=\left(a^2+1\right)\left(b^2+1\right)\)