Example: Differential equation direction plot

Published 2014-03-16 | Author: Jake

Using PGFPlotstable, we can use a naive numerical integration scheme to find the function directly within LaTeX.

This code was written by Jake on TeX.SE.

Download as: [PDF] [TEX]  •  [Open in Overleaf]

Differential equation direction plot

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de.

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.8}
\usepackage{pgfplotstable}
\pgfplotstableset{
    create on use/x/.style={
        create col/expr={
            \pgfplotstablerow/201*2-1
        }
    },
    create on use/y/.style={
        create col/expr accum={
            \pgfmathaccuma+(2/201)*(abs(\pgfmathaccuma^2)+abs(\thisrow{x}^2)-1)
        }{0.6}
    }
}
\pgfplotstablenew{201}\loadedtable
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
      view     = {0}{90},
      domain   = -1:1,
      y domain = -1:1,
      samples  = 21,
      xmax     = 1,
      ymax     = 1
    ]
    \addplot3 [gray, quiver={u={1}, v={x^2+y^2-1}, scale arrows=0.075,
               every arrow/.append style={-latex}}] (x,y,0);
    \addplot [thick, red] table [x=x, y=y] {\loadedtable};
  \end{axis}
\end{tikzpicture}
\end{document}

Comments

Adding comments is currently not enabled.