Illustrate ECC group

tikz-pgf

I'm trying to get a drawing like this in tikz, illustrating an Elliptic Curve group's binary operator.

ECC

I get the curve equation with a single controlling parameter t as (x,y)=(t^2,t(t^2-a)) (here with a=3 and t from -2.1 to 2.1), and can compute t" for P" as (t*t'+a)/(t+t'), with the unmarked point -t".

Update: I kicked me started and get the following, but

  • I did not manage to use my parametric equation with t the controlling variable
  • I don't know how to proceed to define my points and draw a line (I could get their (x,y) coordinates but then?). If only I knew where I declare variables, and how I use them to plot!
  • my node [left=15mm, below=2mm,black] is entirely empirical and super brittle.

Update: t=-3/5, t'=-7/5, t"=-48/25 would do.

\documentclass{amsart}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{figure}[tb]
\begin{tikzpicture}
    \begin{axis}[
        xmin=0, xmax=4.5,
        ymin=-2.5, ymax=2.5,
        xlabel={$x$}, ylabel={$y$},
        domain=0:4.2, samples=400,
        scale only axis, axis lines=middle,
        smooth, axis equal image=true, clip=true,
    ]
        \addplot [thick,purple] {sqrt((x-3)^2*x)}
            node[left=15mm, below=2mm,black] {$y^2=x(x-3)^2$};
        \addplot [thick,purple] {-sqrt((x-3)^2*x)};
    \end{axis}
\end{tikzpicture}
\caption{What I get}
\label{firstfig}
\end{figure}
\end{document}

What I get

Best Answer

With avaiable parameter equations of EEC, I use TikZ for this.

enter image description here

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[>=stealth,declare function={
a=3; 
t1=-1.5;
t2=-.5;
t3=(t1*t2+a)/(t1+t2);       
x(\t)=(\t)^2;         % do not use \t^2
y(\t)=\t*((\t)^2-a);    
}]
\clip (-.5,-2.5) rectangle (4.5,2.5);
\draw[->] (-.5,0)--(4.5,0) node[below left]{$x$};
\draw[->] (0,-2.5)--(0,2.5) node[below left]{$y$};
\draw[magenta,smooth,thick] plot[variable=\t,domain=-2.1:2.1] ({x(\t)},{y(\t)}) node[left=15mm, below=4mm]{$y^2=x(x-3)^2$};

\path 
(0,0) node[below left]{O}
({x(t1)},{y(t1)}) coordinate (P) node[above right]{$P$}
({x(t2)},{y(t2)}) coordinate (Pp) node[below right]{$P'$}
({x(t3)},{y(t3)}) coordinate (Ppp) node[right]{$P''$};

\draw[shorten >=-1cm,shorten <=-2cm] (P)--(Pp);
\draw (Ppp)--+(90:2.5) (Ppp)--+(-90:1.5);
\fill[red] (P) circle(2pt); 
\fill[blue] (Pp) circle(2pt);
\fill (Ppp) circle(2pt);
\end{tikzpicture}
\end{document}
Related Question