[pstricks] implicit plots
Herbert Voss
LaTeX at zedat.fu-berlin.de
Mon Dec 12 23:13:13 CET 2005
Oscar Ecenarro wrote:
> Herbert,
> I'm trying to draw the equipotential lines of a system of two equal
> charges at short distances (not a dipolar field), using the implicit
> plotting scheme that you sugests.
> Briefly, the function to be plotted is:
> V=k(1/r+1/r')
> Placing the origin at the first charge, I use the next definition at the
> pstVerb environment in Cartesian coordinates:
A problem with the Steffensen algorithm for zeros ...
a division by zero. I suppose it is not the right
tool here.
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 % 1/sqrt(x^2+y^2)
1 x 10 sub 2 exp yVal 2 exp add sqrt % 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=200,linecolor=red,polarplot]{-180}{180}{ 2 Steffensen }
\end{pspicture*}
\end{document}
More information about the PSTricks
mailing list