Skip to content

Instantly share code, notes, and snippets.

@maple3142
Created June 5, 2023 13:12
Show Gist options
  • Select an option

  • Save maple3142/8f90cb6aea6c5600f468d0acade89af8 to your computer and use it in GitHub Desktop.

Select an option

Save maple3142/8f90cb6aea6c5600f468d0acade89af8 to your computer and use it in GitHub Desktop.
expressing an irrational in terms of another one
# express sqrt(2) in terms of a rational polynomial of w=sqrt(2)+sqrt(3)+sqrt(5)
w = sqrt(2) + sqrt(3) + sqrt(5)
K = QQ[w]
f = K(2).sqrt().lift()
print(f)
print(f(w).expand())
PR = PolynomialRing(QQ, "x,y,z,r", order="lex")
x, y, z, r = PR.gens()
I = PR.ideal([x ^ 2 - 2, y ^ 2 - 3, z ^ 2 - 5, r - x - y - z])
f = (x - I.groebner_basis()[0]).univariate_polynomial()
print(f)
print(f(w).expand())
# express sqrt(2) in terms of a rational polynomial of w=sqrt(2)+cbrt(3)
w = 2 ^ (1 / 2) + 3 ^ (1 / 3)
K = QQ[w]
f = K(2).sqrt().lift()
print(f)
print(f(w).expand())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment