(a^3+a^2-a-1)/(a^2+2a+1)=((a^3+a^2)-(a+1))/(a+1)^2=
=(a^2(a+1)-(a+1))/(a+1)^2=
=(a+1)(a^2-1)/(a+1)^2=
=(a+1)(a+1)(a-1)/(a+1)^2=a-1
(a^3+a^2-a-1)/(a^2+2a+1)=((a^3+a^2)-(a+1))/(a+1)^2=
=(a^2(a+1)-(a+1))/(a+1)^2=
=(a+1)(a^2-1)/(a+1)^2=
=(a+1)(a+1)(a-1)/(a+1)^2=a-1