Intersection of two field extensions? Let $P,Q \in \mathbb Z[X]$ be irreducible polynomials with roots $\alpha,\beta$ respectively.
I'm interested in the field $\mathbb Q(\alpha) \cap \mathbb Q(\beta)$. I know that it will be expressible in the form $\mathbb Q(\gamma)$ for some algebraic $\gamma$ by the primitive element theorem, the ideal would be to calculate the minimal polynomial of some $\gamma$. To give me a good handle on this intersection field.
So far I have worked out that the degree of the intersection field with be a divisor of the gcd of the degrees of the two fields. This lets me solve the case where we have relatively prime degree. But I'm interested in the case where we have a nontrivial intersection. I have considered trying to factorize $P$ modulo $Q$ and vice versa. I have also looked into the resultant but I think that gives us $\mathbb Q(\alpha,\beta)$ than the intersection.
 A: The key step is to find the minimal polynomial $f\in \Bbb{Q}(\alpha)[x]$ of $\beta$. Then it is some linear algebra.
Let $A=[\Bbb{Q}(\alpha):\Bbb{Q}] = \deg(P)$,$B=[\Bbb{Q}(\beta):\Bbb{Q}]=\deg(Q)$,$C=[\Bbb{Q}(\alpha,\beta):\Bbb{Q}(\alpha)]=\deg(f)$.
From $f$ you know the unique $c_{n,m,k}\in \Bbb{Q}$ such that $$\beta^n = \sum_{m=0}^{A-1} \alpha^m \sum_{k=0}^{C-1}\beta^k c_{n,m,k}$$
Whence $$\Bbb{Q}(\alpha)\cap \Bbb{Q}(\beta) = \{ \sum_{n=0}^{B-1} d_n \beta^n|\ {d\in \Bbb{Q}^B\\\forall m\in 0\ldots A-1\\ \forall k \in 1\ldots C-1}, \sum_{n=0}^{C-1} c_{n,m,k} d_n = 0\}$$
This amounts to find a basis of the kernel of a matrix. Once this is done you know some $\gamma_j\in \Bbb{Q}(\beta)$ such that
$$\Bbb{Q}(\alpha)\cap \Bbb{Q}(\beta) = \oplus_{j=1}^J \gamma_j\Bbb{Q}$$
The primitive element theorem guarantees that for any $r\in \Bbb{Z}$ large enough you'll have $$\Bbb{Q}(\alpha)\cap \Bbb{Q}(\beta)=\Bbb{Q}(s), \qquad s=\sum_{j=1}^J r^j \gamma_j$$
To check if $r$ works: let $S\in \Bbb{Q}^{J\times AC}$ be the matrix whose $j$-th row gives the coefficients of $s^j$ in the $\alpha^m\beta^k$ basis of $\Bbb{Q}(\alpha,\beta)$, and check if $\det(S S^\top) \ne 0$.
Solving the linear equation $v S = (1,0,\ldots),v \in \Bbb{Q}^J$ you'll have the $\Bbb{Q}$-minimal polynomial of $s$ of degree $J$.
