<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<style>
    font{
        line-height: 1.6;
    }
    ul,ol{
        padding-left: 20px;
        list-style-position: inside;
    }
</style>
<div style="font-family:微软雅黑,Verdana,"Microsoft Yahei",SimSun,sans-serif;font-size:14px; line-height:1.6;">
    <div>
    <div>
        <span>Hi, all:
        </span></div><div><span><br></span></div>
    <div><span>Now I want to draw the </span>Weierstrass<span style="line-height: 1.6;"> elliptic curve as following:</span></div><div><span>$$y^2+ay=x^3+bx^2+cxy+dx+e$$</span></div><div>where a,b,c,d,e are coefficients can be input by parameters.</div><div><br></div><div>I need to call <span style="line-height: 22.4px;">\parametricplot twice to draw the following two branches:</span></div><div><div style="line-height: 22.4px;">x(t) = t</div><div style="line-height: 22.4px;">y(t) = 1/2[(ct-a)+sqrt((ct-a)^2+4(t^3+b<span style="line-height: 22.4px;">t</span>^2+d<span style="line-height: 22.4px;">t</span>+e))]</div></div><div>and</div><div><span style="line-height: 22.4px;">x(t) = t</span></div><div><span style="line-height: 22.4px;">y(t) = 1/2[(ct-a)-sqrt((ct-a)^2+4(</span><span style="line-height: 22.4px;">t</span><span style="line-height: 22.4px;">^3+b</span><span style="line-height: 22.4px;">t</span><span style="line-height: 22.4px;">^2+d</span><span style="line-height: 22.4px;">t</span><span style="line-height: 22.4px;">+e))]</span></div><div><br></div><div>So I define a new command \<span style="line-height: 22.4px;">pstEllipticCurve </span><span style="line-height: 1.6;">as following:</span></div><div><span style="line-height: 1.6;"><br></span></div><div><div>%% \pstEllipticCurve[Options]{a,b,c,d,e}{t1}{t2}</div><div>%% draw the elliptic curve <span style="line-height: 22.4px;">$y^2+ay=x^3+bx^2+cxy+dx+e$ </span><span style="line-height: 1.6;">from t1 to t2.</span></div><div>%% Parameters:</div><div>%% #1 -> options</div><div>%% #2..#6 -> [input] the coefficients of elliptic curve</div><div>%% #7 -> [input] draw the elliptic curve from t1 to t2.</div><div>%% #8 -> [input] draw the elliptic curve from t1 to t2.</div><div>\def\pstEllipticCurve{\@ifnextchar[\Pst@EllipticCurve{\Pst@EllipticCurve[]}}</div></div><div><div>\def\Pst@EllipticCurve[#1](#2,#3,#4,#5,#6)#7#8{%</div><div>  \begingroup</div><div>    \psset{#1}%</div><div>    \parametricplot{#7}{#8}{%</div><div>       % a, b, c, d, e, t</div><div>       #2 #3 #4 #5 #6 t</div><div>       0 index 4 index mul 6 index sub % cx-a</div><div>       1 index 6 index add 2 index mul % (x+b)x</div><div>       4 index add 2 index mul % ((x+b)x+d)x</div><div>       3 index add % ((x+b)x+d)x+e</div><div>       4 mul % 4(((x+b)x+d)x+e)</div><div>       1 index dup mul add</div><div>       dup 0 lt {</div><div><span style="line-height: 1.6;">         </span>pop pop pop pop pop pop pop pop t 0</div><div><span style="line-height: 1.6;">       } {</span></div><div>         sqrt 1 index add 2 div</div><div>         exch pop 7 2 roll pop pop pop pop pop</div><div>       } ifelse</div><div>    }%</div><div>    \parametricplot{#7}{#8}{%</div><div>       % a, b, c, d, e, t</div><div>       #2 #3 #4 #5 #6 t</div><div>       0 index 4 index mul 6 index sub % cx-a</div><div>       1 index 6 index add 2 index mul % (x+b)x</div><div>       4 index add 2 index mul % ((x+b)x+d)x</div><div>       3 index add % ((x+b)x+d)x+e</div><div>       4 mul % 4(((x+b)x+d)x+e)</div><div>       1 index dup mul add</div><div>       dup 0 lt {</div><div><span style="line-height: 1.6;">         </span>pop pop pop pop pop pop pop pop t 0</div><div>       } {</div><div>         sqrt 1 index exch sub 2 div</div><div>         exch pop 7 2 roll pop pop pop pop pop</div><div>       } ifelse</div><div>    }%</div><div>  \endgroup%</div><div>}%</div></div><div><br></div><div>I just push the point (t,0) to the stack if the sqrt operand less then zero, which will cause parametricplot draw a unexpected line on the x-axis,</div><div>the output pdf file is attached.</div><div><br></div><div>The test code as following:</div><div><br></div><div>\begin{pspicture}[showgrid=true](0,0)(4,4)</div><div>% y^2=x^3-3x+3</div><div>\pstEllipticCurve[linecolor=red](0,0,0,-3,3){-3}{3}</div><div>\psplotImp[linecolor=blue!30](-10,-10)(10,10){ x dup dup mul mul -3 x mul add y dup mul sub 3 add }</div><div>\end{pspicture}</div><div><br></div><div>So the question is, how can I skip the invalid points when using \parametricplot? </div><div><br></div><div>I have an idea is to push a string <span style="line-height: 22.4px;">(nan)</span><span style="line-height: 22.4px;"> </span><span style="line-height: 1.6;">into the stack and then modify the macro \parametricplot to check the type of value and don't draw them out.</span></div><div><span style="line-height: 1.6;">but I can not modify \</span><span style="line-height: 22.4px;">parametricplot by myself</span><span style="line-height: 22.4px;"> to archive this function. </span></div><div><span style="line-height: 22.4px;"><br></span></div><div>first, push a string (nan) into the stack in the postscript code where I call \<span style="line-height: 22.4px;">parametricplot</span><span style="line-height: 1.6;">:</span></div><div><div style="">        dup 0 lt {</div><div style=""><span style="line-height: 1.6;">  <font color="#ff4312">         pop pop pop pop pop pop pop pop t (nan)</font></span></div><div style=""><span style="line-height: 1.6;">        } {</span></div><div style="">          sqrt 1 index add 2 div</div><div style="">          exch pop 7 2 roll pop pop pop pop pop</div><div style="line-height: 22.4px;">        } ifelse</div></div><div style="line-height: 22.4px;"><br></div><div><span style="line-height: 22.4px;">then try to check the type of value y in \</span><span style="line-height: 22.4px;">parametricplot: </span></div><div><div style="">     /xy {</div><div style="">         \ifPst@algebraic F@pstplot \else #5 \fi</div><div style=""><span style="line-height: 1.6;"><font color="#ff4312">         dup type (realtype) ne { % if y is not a real number</font></span></div><div style=""><font color="#ff4312">           pop pop false</font></div><div style=""><font color="#ff4312">        } {</font></div><div style=""><font color="#ff4312">          \pst@number\psyunit mul exch</font></div><div style=""><font color="#ff4312">          \pst@number\psxunit mul exch</font></div><div style=""><font color="#ff4312">          true</font></div><div style=""><font color="#ff4312">        } ifelse</font></div><div style="">     } def</div><div style="line-height: 22.4px;">and modify the code when we use xy to check the last value on stack is false or true.</div></div><div><br></div>
    <div id="ntes-pcmac-signature" style="font-family:'微软雅黑'">
        
        <div style="font-size:14px; padding: 0;  margin:0;">

        </div>
    </div>
</div><!--😀-->
</div>
</body>
</html>