g | x | w | all
Bytes Lang Time Link
nan230908T062604Z138 Aspe
175Wolfram Language Mathematica211224T032104Zalephalp
nan211224T022214Zcaird co

Trivial builtin answers

Python + sympy, 46 bytes

Saved 32 bytes thanks to @Stef


46 bytes version. Attempt This Online!

lambda y:degree(minpoly(y));from sympy import*

78 bytes version. Attempt This Online!

from sympy import*
x=symbols('x')
f=lambda y:degree(minimal_polynomial(y,x),x)

Wolfram Language (Mathematica), 175 bytes

Cases[FactorList@g@#,{y_,_}/;Simplify[y/.x->#/.s->D]==0:>y~Exponent~x]&
g@n_=x-n
g[p_~s@o_~q_]:=Resultant[g@q,g@p/.x-><|Plus->z-x,Times->z/x,Divide->z*x,Surd->z^q|>@o,x]/.z->x

Try it online!

Takes an expression as input, where:

For example, \$\sqrt[5]5+\sqrt[7]3-2\sqrt[2]2\$ is represented by s[Plus][s[Plus][s[Surd][5, 5], s[Surd][3, 7]], s[Times][-2, s[Surd][2, 2]]].

The idea is constructing a (usually not minimal) polynomial using resultants, factoring it, and choosing the correct factor. The last step requires checking whether a expression is equal to zero. I'm not sure if Simplify is powerful enough for all possible inputs, but at least it works for all the testcases.

Trivial builtin answers

Wolfram Language (Mathematica), 33 bytes

#~MinimalPolynomial~x~Exponent~x&

Try it online!

Unsurprisingly, MinimalPolynomial returns the minimal polynomial of its input, and Exponent gets the highest exponent in this polynomial. We use a bit of infix notation (a~f~b is f[a,b]) to save a couple of bytes, and so this translates as

#~MinimalPolynomial~x~Exponent~x&
Exponent[#~MinimalPolynomial~x,x]&
Exponent[MinimalPolynomial[#,x],x]&