Let us first convert #(x^2-2x-1)/((x-1)^2(x^2+1))# to partial fractions. For this let
#(x^2-2x-1)/((x-1)^2(x^2+1))hArrA/(x-1)+B/(x-1)^2+(Cx+D)/(x^2+1)#
or #(x^2-2x-1)/((x-1)^2(x^2+1))=(A(x-1)(x^2+1)+B(x^2+1)+(Cx+D)(x-1)^2)/((x-1)^2(x^2+1))#
or #(x^2-2x-1)=A(x-1)(x^2+1)+B(x^2+1)+(Cx+D)(x-1)^2#
Putting #x=1# in this we get #2B=-2# or #B=-1#
Comparing coefficient of highest degree i.e. #x^3#, we get #A+C=0#,
comparing constant term we get #-A+B+D=-1# or #-A+D=0# i.e. #A=D#
and comparing coefficient of #x#, #-2=A-2D+C# i.e. #C-A=-2#
as #A+C=0#, we get #C=-1# and #A=1# and hence
#(x^2-2x-1)/((x-1)^2(x^2+1))=1/(x-1)-1/(x-1)^2-(x-1)/(x^2+1)#
Hence #int(x^2-2x-1)/((x-1)^2(x^2+1))dx#
= #intdx/(x-1)-intdx/(x-1)^2-int(x-1)/(x^2+1)dx#
= #ln|x-1|+1/(x-1)-1/2int(2x)/(x^2+1)dx+intdx/(x^2+1)#
= #ln|x-1|+1/(x-1)-1/2ln(x^2+1)+tan^(-1)x+c#