I cannot spot where I am going wrong in this. I am using Extended Euclidean's algorithm here.
$(x^5+x^2+1) = (x^4)(x) + (x^2+1)$
$(x^4) = (x^2+1)(x^2+1) + 1$
let $P(x)=x^4$ and $Q(x)=x^5+x^2+1$
$(x^5+x^2+1) + (x^4)(x) = (x^2+1)$
$(x^4) + (x^2+1)(x^2+1) = 1$
$P(x)+[Q(x)+P(x)(x)][Q(x)+P(x)(x)]=1$
$P(x)(1+xQ(x)+P(x)x^2+xQ(x)) +Q(x)(...)=1$
$P(x)(1+P(x)x^2)+Q(x)(...)=1$
$P(x)(1+x^6) + Q(x)(...)=1$
$(1+x^6) \bmod (x^5+x^2+1)=x^3+x+1$
I am getting the inverse of $x^4 \mod (x^5+x^2+1)$ as $x^3+x+1$ but it seems the right answer is $x^4+x^2+1$. Can anyone tell me where it is wrong?
Your answer is correct since, taking into account that the characteristic of the field is $2$, so that $x^5=x^2+1$, \begin{align} x^4(x^3+x+1)&=x^7+x^5+x^4=x^7+x^4+x^2+1 \\ &=x^2\cdot x^5+x^4+x^2+1=\color{red}{\not x^4}+\color{blue}{\not x^2}+\color{red}{\not x^4}+\color{blue}{\not x^2}+1\\ &=1. \end{align}