[pstricks] implicit plots

Herbert Voss LaTeX at zedat.fu-berlin.de
Tue Dec 13 23:17:24 CET 2005


Oscar Ecenarro wrote:

> First, the /func definition has a mistake:
>  
>       1 x 2 exp yVal 2 exp add sqrt % 1/sqrt(x^2+y^2)
>       1 x 10 sub 2 exp yVal 2 exp add sqrt  % 1/sqrt((x-10)^2+y^2)
> 
> must be replaced by
>  
>       1 x 2 exp yVal 2 exp add sqrt div% 1/sqrt(x^2+y^2)
>       1 x 10 sub 2 exp yVal 2 exp add sqrt div % 1/sqrt((x-10)^2+y^2)

oh, yes.
  However, the Steffensen algorithm for the zeros seems
to be not the best here, try another one, like Newton.

Herbert

\documentclass[12pt]{article}%
\usepackage{pstricks}%
\usepackage{pstricks-add}%
\begin{document}

\begin{pspicture*}(-5,-2.5)(5,2.5)
\psaxes(0,0)(-5,-2.5)(5,2.5)%
\pstVerb{
    /eps1 0.0001 def % x
    /eps2 0.001 def % x
    /MaxIter 10 def
%------------------------ the implicit function -----------------------
    /func { % parameter is the y value
      /yVal ED
      1 x 2 exp yVal 2 exp add sqrt div % 1/sqrt(x^2+y^2)
      1 x 10 sub 2 exp yVal 2 exp add sqrt div % 1/sqrt((x-10)^2+y^2)
     add % add both
    1 sub
    } def
%------------------------ the implicit function -----------------------
    /Steffensen {
      /y0 ED % the start value
      /Iter 0 def
      {
        y0 func /F ED
        F abs eps2 lt { exit } if
        y0 F sub /Phi ED
        Phi func /F2 ED
        F2 abs eps2 le { exit }{%
          Phi y0 sub dup mul Phi F2 sub 2 Phi mul sub y0
	 add dup abs eps1 gt { div } { pop } ifelse /Diff ED
          y0 Diff sub /y0 ED
          Diff abs eps1 le { exit } if
        } ifelse
        /Iter Iter 1 add def
        Iter MaxIter gt { exit } if
      } loop
      y0
    } def
}
  \psplot[plotpoints=400,linecolor=red]{0}{2}{ .1 Steffensen }
\end{pspicture*}

\end{document}




More information about the PSTricks mailing list