Ask Your Question
1

Drawing a line not segment

asked 2021-01-15 13:10:24 +0100

klx gravatar image

updated 2021-01-15 14:37:05 +0100

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?

edit retag flag offensive close merge delete

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 ( 2021-01-15 14:16:29 +0100 )edit

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

klx gravatar imageklx ( 2021-01-15 14:37:59 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-01-15 22:48:20 +0100

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")
edit flag offensive delete link more

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 ( 2021-01-15 23:58:51 +0100 )edit

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 ( 2021-01-16 04:53:52 +0100 )edit

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

klx gravatar imageklx ( 2021-01-16 15:50:02 +0100 )edit

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: 2021-01-15 13:10:24 +0100

Seen: 334 times

Last updated: Jan 15 '21