# Taking gcd with respect to one variable

I want to compute $$ gcd_{X}((X-y)^2 -a , X^{\frac{q-1}{2}}-1)$$ with respect to X(taking y as a field constant).

I can't see any direct implementation of this in sage. Can any one suggest how to implement it.

Here Arithmetic is over $GF(p)$ and y is root of cyclotomic polynomial of degree r over $GF(p)$ and $q = p^r$

One can choose 'a' to be any quadratic residue modulo p

I tested what I think should be the standard way of doing this computation in Sage. Unfortunately, an implementation is lacking, and it does not work: