# Plotting polynomials defined over a number field

I have an element of a polynomial ring over a number field K. It's a pretty benign number field -- I have just adjoined a square root of 3, called 't'.

I want to be able to plot the polynomial (specifically, it's a polynomial of two variables, and I want an implicit plot of where it vanishes). How do I get Sage to coerce 't' to a real number and draw the plot? Of course this should involve fixing an embedding of my number field into RR, but it's just a square root, so this shouldn't be hard.

For a minimal example:

var('w')
K.<t> = NumberField(w^2-3)
R = PolynomialRing(K,2,'x,y')
R.inject_variables()
f = y - t*x
implicit_plot(f,(x,-3,3),(y,-3,3))


It (quite understandably) chokes with "TypeError: Unable to coerce -t to a rational". I would like to coerce t to be the positive real square root of 3 and draw the plot.

edit retag close merge delete

Sort by » oldest newest most voted You have the right idea: do f.change_ring(R) with the argument R set to one of K.embeddings(RR):

var('w')
K.<t> = NumberField(w^2-3)
R.<x,y> = PolynomialRing(K)
f = y - t*x
implicit_plot(f.change_ring(K.embeddings(RR)),(x,-3,3),(y,-3,3))


You might also like:

implicit_plot(f.change_ring(K.embeddings(RR)),(x,-3,3),(y,-3,3), color='blue') + implicit_plot(f.change_ring(K.embeddings(RR)),(x,-3,3),(y,-3,3), color='red')

more