# Computing the inverse of a generic element in a finite field extension

I am working in the following field extension:

```
p = 2**64-2**32+1
P.<X,A,B,C> = PolynomialRing(GF(p))
GF.<x,a,b,c> = P.quotient_ring(X^3-X-1)
```

My objective is to take a generic element of this field `p(x) = a + b*x + c*x^2`

and compute its inverse, where its coefficients are a function of `a,b,c`

.

However, if I try to directly do it:

```
q = x^2
qinv = 1 / q
```

I get a singular error. I get an error (`ArithmeticError: Division failed. The numerator is not a multiple of the denominator.`

) if I change the prime to, say, 5. If I do not use the variables to express the generic coefficients of `p(x)`

, then clearly it works, but I do not get the desired result.

Is there any way I can achieve what I need?