1

I'm using Beamer and I desperately need to have a picture of the following image: the elliptic curve $y^2=x^3+17$, with points R = (-2, -3), -R = (-2, 3), P = (4,9) and Q=(2,5). I'd also like a straight line through R, P and Q. How can i go about drawing this?

Many thanks!

percusse
  • 157,807
Luke
  • 11
  • When I had to create some pictures of elliptic curves, I used Python because for some reason (I can't actually remember now) I was not too happy with what I could come up with using pgfplots and friends. But there seem to be good ways to do this using pgf/pstrickst etc., see https://pbelmans.wordpress.com/2010/11/11/howto-draw-algebraic-curves-using-pgftikz/, https://cryptojedi.org/misc/pstricks.shtml and https://amca01.wordpress.com/2008/04/27/mathematical-diagrams/ – moewe Dec 04 '14 at 16:49

2 Answers2

5

Implicit functions are the weak side of TeX based plotting. You can either call the big brother gnuplot(see pgfplots manual) to save or you can divide the domain of definition and plot separately.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[no marks,samples=200,domain=-2.571281:5,grid=both]
\addplot[blue] {sqrt(x^3+17)};
\addplot[blue] {-sqrt(x^3+17)};
\coordinate[label={90:$R$}] (R) at (axis cs:-2,3);
\coordinate[label={-90:$-R$}] (-R) at (axis cs:-2,-3);
\coordinate[label={90:$P$}] (P) at (axis cs:4,9);
\coordinate[label={90:$Q$}] (Q) at (axis cs:2,5);
\draw (P) -- (Q) -- (-R);
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

percusse
  • 157,807
  • That's awesome! thanks! Is it possible to get the line to extend to infinity, though? And possibility the actual coordinates labelled as well as R, P, Q, -R? it's my fault for not specifying that. – Luke Dec 04 '14 at 17:15
  • @Luke You can either use shorten > or shorten < keys or via calc library of tikz \draw ($(P)!-1!(-R)$) -- ($(P)!2!(-R)$);. I don't know what you mean by actual coordinates – percusse Dec 04 '14 at 17:40
  • i tried copying and pasting your source code and it wouldn't compile for some reason... By actual coordinates, I mean R to have the label (-2, -3) as well, etc – Luke Dec 04 '14 at 17:51
  • You can use the labels to whatever you wish to typeset. Without the actual error I can't guess what the problem is. – percusse Dec 04 '14 at 20:07
1

You could also draw this sort of plot with Metapost. Compile with mpost and include the .eps file it produces with \includegraphics.

enter image description here

prologues := 3;
outputtemplate := "%j%c.eps";

beginfig(1);

u = 1.44cm; % horizontal unit
v = 3.2mm;  % vertical unit

% axes
path xx, yy;
xx = (3 left -- 6 right) scaled u;
yy = (14 down -- 14 up) scaled v;

drawarrow xx withcolor .6 white;
drawarrow yy withcolor .6 white;

% the curve
path half_curve, full_curve;
root = -(17**1/3);
s = 0.1;
half_curve = (root, 0) for x=root+s step s until 5.4: .. (x, sqrt(17+x**3)) endfor;
full_curve = (reverse half_curve reflectedabout(left,right) & half_curve) xscaled u yscaled v;
draw full_curve withcolor .67 red;

% the points
pair R, P, Q;
R = (-2u,-3v);
P = (4u,9v);
Q = (2u,5v);

% the line through R and P
z1 = whatever[R,P]; x1 = -3u;
z2 = whatever[R,P]; x2 = +6u;
draw z1--z2;

% labels
dotlabel.top(btex $P$ etex, P); label.lrt(btex $(4,9)$ etex, P);
dotlabel.top(btex $Q$ etex, Q); label.lrt(btex $(2,5)$ etex, Q);
fill fullcircle scaled dotlabeldiam shifted R;
label(btex $R$ etex, R+8 up);
label(btex $(-2,-3)$ etex, R+14 down);
dotlabel.ulft(btex $-R$ etex, R reflectedabout(left,right));

endfig;
end.
Thruston
  • 42,268