5

I'm triyng to draw the following vector field

$F(x,y) = \frac{\sqrt{2}x}{\sqrt{x^2 + y^2}} \mathbf{i} + \frac{\sqrt{2}y}{\sqrt{x^2 + y^2}} \mathbf{j}$

using \psVectorfield command. The plot given by Maple is

enter image description here

6
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pstricks-add}
\begin{document}
\begin{pspicture}[showgrid](-7,-7)(7,7)
    \multido{\ix=-5+1}{11}{\multido{\iy=-5+1}{11}{%
        \ifnum\numexpr\ix*\ix+\iy*\iy\relax=0\relax
        \else
            \rput(\ix,\iy){\psline[linecolor=red,ArrowInside=->](!\ix\space \iy\space 2 copy Pyth dup 3 1 roll div 3 1 roll div 2 sqrt dup 3 1 roll mul 3 1 roll mul)}
        \fi
    }}
\end{pspicture}
\end{document}

enter image description here

  • Artificial Stupidity, please, see graph above. – Artur Nov 25 '18 at 16:51
  • Yes it is. And a potential function is $\sqrt(2*x^2 + 2*y^2)$. But both graphs do not seem similar... – Artur Nov 25 '18 at 17:12
  • I do not think that this is the gradient field for U = (2x^2 + 2y^2) ^ (1/2). U has a rotational symmetry, which your plot does not have. – user121799 Nov 25 '18 at 17:31
  • Thanks to all for the comments (and graphs). One more additional question: excluding 100 pages pst-plot-doc pdf, where I can find more information (if any) about \psVectorfield command? – Artur Nov 25 '18 at 18:09
3

Meanwhile a pgfplots alternative.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={0}{90},domain=-4:4]
\addplot3 [blue,-stealth,samples=16,
        quiver={
            u={2*x/pow(x^2 + y^2,1/2)},
            v={2*y/pow(x^2 + y^2,1/2)},
            scale arrows=0.2,
        },
    ] { 1}; % use pow(x^2 + y^2,1/2) if you choose to have a real 3D plot
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

2
\documentclass[pstricks,border=1cm]{standalone}
\usepackage{pst-plot,pst-ode}
\psset{unit=3,algebraic}
\begin{document}

\begin{pspicture}(-1.1,-1.1)(1.1,1.1)
  \psclip{\psframe[linestyle=none,linewidth=0](0,-1)(1,1)}
    \psVectorfield[linecolor=red](0.1,-1)(1,1){y/x}
  \endpsclip%
  \psclip{\psframe[linestyle=none,linewidth=0](-1,-1)(0,1)}
    \psVectorfield[linecolor=red,Dx=-0.1](-1,-1)(0.1,1){y/x}
\endpsclip%
  \psaxes[ticksize=0 4pt,axesstyle=frame,tickstyle=inner,subticks=20,Ox=-1,Oy=-1](-1,-1)(1,1)
  \psaxes[linecolor=red,ticks=none,labels=none,linewidth=0.2pt](0,0)(-1,-1)(1,1)
\end{pspicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.