[pstricks] Making Direction Fields; also coordinates as functions inside loops
Michael M. Dougherty, Ph.D.
doughem at swosu.edu
Sun Jan 7 18:31:09 CET 2001
Fellow PsTricksters,
I would like to plot a direction field for some simple
ordinary differential equations without plotting the
vectors or line segments each individually. In other
words I would like to use loops, perhaps to make
a vector or line segment at/through each point with integer
coordinates. For instance, I would like to plot
a field for $dy/dx=-x/y$ (and later plot some circles
which are the solution curves--that I can do). I would
like the method to be more general than for just this one, but
hopefully this one will suffice to start.
Therefore I need the coordinates of the line segments/vectors
to be functions of $x$ and $y$. I was hoping to use multido
but I do not know how to calculate the coordinates of
the endpoints of the line segments or vectors within the loop.
This is my first attempt at multido, but I do understand how
to plot functions (so I know about RPN). Here's the code
I'm looking at:
\begin{pspicture}(-6,-5)(6,5)
\psaxes{<->}(0,0)(-6,-5)(6,5)
\multido{\n=-5+1}{11}{%
\multido{\N=-5+1}{11}{%
%%%%%%% WHAT TO PUT HERE?
%%%%%%% Want\psline((\n-1/(2\sqrt{1+x^2/y^2}),\N-x/(2*y\sqrt{1+%
%%%%%%% x^2/y^2})),((n+1/(2\sqrt{1+x^2/y^2}),\N+x/(2*y\sqrt{1+%
%%%%%%% x^2/y^2})).
}}
\end{pspicture}
Please don't let the ugliness of the calculation distract.
I only would like to know if it is possible to compute these
coordinates inside the loop and enter them as arguments
of \psline and the like. (Of course I will have to
avoid the (y=)\N=0 and do those points separately to avoid
dividing by zero.)
Or if anyone has found another way to draw direction fields
without resorting to Mathematica, etc., but inside LaTeX
I would appreciate any guidance.
Thank you for your consideration.
--
Michael M. Dougherty
Assistant Professor of Mathematics
Southwestern Oklahoma State University
(580) 774-3057
More information about the PSTricks
mailing list