I am working on a problem that I can not seem to finish.
Find the gcd of $f(x)=x^7+1$ and $g(x)=x^6+x^5+x^3+1$, and express it in the form $a(x)f(x)+b(x)g(x)$ using the extended euclidean algorithm.
I have performed the extended euclidean algorithm to find the following $$f(x)=(x-1)g(x)+(x^5-x^4+x^3-x+2)$$ $$g(x)=(x+2)(x^5-x^4+x^3-x+2)+(x^4-x^3+x^2-3)$$ $$x^5-x^4+x^3-x+2=(x)(x^4-x^3+x^2-3)+(2x+2)$$ $$x^4-x^3+x^2-3=(\frac{1}{2}x^3-x^2+\frac{3}{2}x-\frac{3}{2})(2x+2)+0$$ This should give us the GCD as following $$\gcd(f,g)=\gcd(x^5-x^4+x^3-x+2, 2x+2)=2x+2$$ And the monic GCD then becomes $$\gcd(f,g)=x+1$$
This is where I get stuck. Now that I have this I am not sure how to algebraically get back to the form $a(x)f(x)+b(x)g(x)$
The answer as provided in the solutions is $$\gcd(f(x),g(x))=x^4+x^3+x^2+1=xf(x)+(x^2+x+1)g(x)$$
I do not understand how to proceed and get to the answer. I have tried going backward but I am not getting anywhere. How do I go from $x+1$ to the correct solution?