Ask Your Question
1

Drawing a line not segment

asked 4 years ago

klx gravatar image

updated 4 years ago

I want to draw a line passing through a point P and Q on an elliptic curve.

E = EllipticCurve([0,0,0,4,20])
print(E)
E.plot(xmin=-20, xmax=20, ymin=-20, ymax=20)
plotE = E.plot()
P=E(1,5)
R = - (P + P)
plotE += line([P.xy(),R.xy()],color='red')

Using this only draw a line segment from P to Q. How can I draw a line? I've looked on the doc but did not see an option for this. Any solution?

Preview: (hide)

Comments

Please provide complete code that can be copied and pasted in a fresh Sage session.

Currently we are missing the definitions of E, P and R.

slelievre gravatar imageslelievre ( 4 years ago )

@slelievre Thought that was not necessary, here it is.

klx gravatar imageklx ( 4 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 4 years ago

Juanjo gravatar image

You can easily plot a segment between two suitable points on the line passing by P and R. For example, you can replace plotE += line([P.xy(),R.xy()],color='red') by:

vP, vR = vector(P.xy()), vector(R.xy())
PR = (vR - vP).normalized()
plotE += line([vP-5*PR, vP+4*PR], color="red")
Preview: (hide)
link

Comments

PR = (lift(vR - vP)).normalized() is needed and after that TypeError: unsupported operand parent(s) for -: 'Vector space of dimension 2 over Finite Field of size 29' and 'Vector space of dimension 2 over Symbolic Ring' on the last line

klx gravatar imageklx ( 4 years ago )

I don't understand why you need lift and have and error. See the full code correctly running in this SageMath Cell.

Juanjo gravatar imageJuanjo ( 4 years ago )

Sorry, cells mixed! I have put it into a curve defined over GF. Yes, it is working. Thanks.

klx gravatar imageklx ( 4 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 4 years ago

Seen: 367 times

Last updated: Jan 15 '21