# Where do I fail with pst-intersect package?

\documentclass[border=10pt,pstricks]{standalone}
\usepackage{pst-plot,amsmath,xfp,pst-intersect}
\begin{document}
\psset{unit=1.25cm}
\def\Func{x^2} % y=x^2
\def\Iy#1{#1^2+1/4} % \delta = b^2-4ac = 4R^2+1-4Iy => Iy=(4R^2+1)/4
\multido{\rA=1+0.1}{10}{% \rA is R
\begin{pspicture}[algebraic,plotstyle=curve](-2,-1)(2,5)
\pnodes(0,\fpeval{\Iy{\rA}}){I}(0,\fpeval{\rA+\fpeval{\Iy{\rA}}}){M}
\psaxes[labels=none,ticks=none]{->}(0,0)(-2,-1)(2,5)[$x$,-90][$y$,0]
\uput[-135](0,0){$O$}
\uput{3pt}[35](I){\small $I(0,\dfrac{5}{4})$}
\psdot[linecolor=blue](I)
\pssavepath{Circle}{\pscircle[linecolor=red](I){\rA}}
\pssavepath{Func}{\psplot{-2}{2}{x^2}}
\psintersect[showpoints]{Circle}{Func}
\end{pspicture}}
\end{document}


As I see, intersection is fail. How to fix it? ( or my code is fail :) )

Quite conceivably the issue is that the parabola graph is a collection of small stretches, which do have more intersections than the "true" parabola. That is, the slopes of the stretches are such that there can be two intersections. I tried to illustrate this in this plot:

One should also mention, given that this is written in (La)TeX, the intersections you get are actually pretty good.

Therefore, in simple cases like this, you may want to just determine the intersections analytically. Here is a simple TikZ code that illustrates this.

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\foreach \X in {0.5,0.6,...,2}
{\begin{tikzpicture}[thick]
\draw[-stealth] (-3,0) -- (3,0) node[below left]{$x$};
\draw[-stealth] (0,-1) -- (0,2.5*2.5+0.5) node[below left]{$y$};
\draw (-2.5,2.5*2.5) parabola bend (0,0) (2.5,2.5*2.5);
\end{tikzpicture}}
\end{document}


This analytic solution can of course also used with PSTricks... (I am aware that the labeling of I may have an issue, but I just copied it from the question.)

\documentclass[border=10pt,pstricks]{standalone}
\usepackage{pst-plot,amsmath,xfp}
\begin{document}
\psset{unit=1.25cm}
\def\Func{x^2} % y=x^2
\def\Iy#1{#1^2+1/2} % \delta = b^2-4ac = 4R^2+1-4Iy => Iy=(4R^2+1)/4
\multido{\rA=0.6+0.1}{12}{% \rA is x
\begin{pspicture}[algebraic,plotstyle=curve](-2,-1)(2,5)
\pnode(0,\fpeval{\Iy{\rA}}){I}
\psaxes[labels=none,ticks=none]{->}(0,0)(-2,-1)(2,5)[$x$,-90][$y$,0]
\uput[-135](0,0){$O$}
\uput{3pt}[35](I){\small $I(0,\dfrac{5}{4})$}
\psdot[linecolor=blue](I)
\pscircle[linecolor=red](I){\fpeval{sqrt(\rA*\rA+1/4)}}
\psplot{-2}{2}{x^2}
\psdots(-\rA,\fpeval{\rA*\rA})(\rA,\fpeval{\rA*\rA})
\end{pspicture}}
\end{document}


• Unfortunately, you have choosed TikZ instead of PSTricks ... – justonly Oct 16 at 11:39
• @justonly I added a PSTricks code. I was using PSTricks for almost 20 years, and forgot many things, and this exercise made me realize how convenient the parser of TikZ is. – Schrödinger's cat Oct 16 at 12:34

You already had the solution with your other question! How to write PostScript commands for "calculation" and "intersection" in the following problem?

The radius is \rx/sin(alpha). That's all ....

\documentclass{standalone}
\usepackage{libertinus}
\pagestyle{empty}
\begin{document}
\def\a{1}
\def\func{\a*x^2}
\def\rx{1.5 }
\begin{pspicture}[showgrid=false,algebraic](-2.5,-0.75)(7.2,7.5)
\psplot{-1.75}{2.5}{\func}\pnode(!1.5 dup dup mul \a\space mul){Pp}\psdot(Pp)\uput[125](Pp){$P_p$}
\pnode(!\rx \radius \psAlpha RadtoDeg sin mul add \radius){Pk}\psdot(Pk)\uput[90](Pk){$P_k$}%
\pnode(!0 \psGetNodeCenter{Pp}\psGetNodeCenter{Pk}Pp.y dup add Pk.y sub){Pki}\psdot(Pki)\uput[45](Pki){$P_{ki}$}%
\psdot(Pk|0,0)\uput[-90](Pk|0,0){$P_x$}
\pscircle(Pki){\fpeval{\rx/sin(\psAlpha)}}%
\pscustom[fillstyle=solid,fillcolor=gray!50!orange,linestyle=none,opacity=0.6]{%
\psplot{0}{\rx}{\func}
}%
\psaxes[labels=none,ticks=none]{->}(0,0)(-2,-0.5)(7,7)[$x$,0][$y$,90]
\rput[rb](2,4){$y=ax^2$}\rput[lb](2.3,4){$y_T$}
\pnode(!\rx dup mul \a\space mul neg \psAlpha RadtoDeg tan div \rx add 0){yT0}
\pcline[linestyle=dashed,nodesepB=-4cm](yT0)(Pp)
\pcline[linestyle=dashed,nodesepA=-2cm,nodesepB=-1cm](Pp)(Pk)
\pcline[linestyle=dashed,nodesep=-1cm](Pp|Pk)(Pk)
\pcline[linestyle=dashed](Pk|0,0)(Pk)\nbput{$r$}
\pcline[linestyle=dashed](Pp)(Pp|0,0)\uput[-90](Pp|0,0){$x_{P_p}$}
\rput(yT0){\rput(0.3;30){$\alpha$}}
\ncline[linestyle=none]{Pp}{Pk}\naput{$r$}
\psarc{->}(Pp){0.5}{-90}{!90 \psAlpha RadtoDeg sub neg}\rput(Pp){\rput(0.3;-50){$\alpha$}}
\pcline[offset=-0.25,arrows=|-|](Pp|Pk)(Pk)\ncput*{$\scriptstyle r\cdot\sin\alpha$}