Simplify $\mathbb{Q}(\pi^3+\pi^2, \pi^8+\pi^5)$

Let $a=\pi^3+\pi^2$ and $b=\pi^8+\pi^5$. Then

$$ \pi=\frac{3b(1-a)+(a^4+3a^3)}{b(a-3)+(3a^3+3a^2)} $$

so you can take $f(\pi)=\pi$. How did I obtain this formula ? I tried to find the minimal polynomial of $\pi$ over ${\mathbb Q}(a,b)$, by applying the Euclidean algorithm to $X^3+X^2-a$ and $X^8+X^5-b$.

The last nonzero term produced by this algorithm is $3b(1-a)+(a^4+3a^3)-X(b(a-3)+(3a^3+3a^2))$.


Let $\alpha = \pi^3+\pi^2$ and $\beta = \pi^8+\pi^5$. It can be shown that if $f = \frac{p}{q}$ where $\gcd(p,q)=1$, we have $$[\mathbb{Q}(\pi):\mathbb{Q}(f(\pi))] = \max\{\deg(p), \deg(q)\}.$$ Therefore $[\mathbb{Q}(\pi):\mathbb{Q}(\pi^3+\pi^2)]=3$, and if $\pi \notin \mathbb{Q(\alpha, \beta)}$, we must have $\mathbb{Q(\pi)}:\mathbb{Q(\alpha, \beta)}=3$, since $$[\mathbb{Q}(\pi):\mathbb{Q}(\alpha)] = [\mathbb{Q}(\pi):\mathbb{Q}(\alpha, \beta)][\mathbb{Q}(\alpha, \beta):\mathbb{Q}(\alpha)].$$

This means that $\beta \in \mathbb{Q}(\alpha)$, or $\pi^8+\pi^5 = \frac{g}{h}$ where $g,h \in \mathbb{Q}[\alpha]$ and are relatively prime. So $\pi^5|g$ which is impossible, because if $\pi^k |g$, $k$ must be even. So $\pi \in \mathbb{Q}(\alpha, \beta)$.