0

How to get the following plot only using latex (TikZ package) of the system of differential equations:

u ’ = u (1 - u) - (a u v)/(u + d)

v ’ = b v (1 - v/u)

a=1, b=0.2,d=0.25.

I don't need the direction fields. I can draw the nullclines as below:

\documentclass[tikz]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
      \draw[->] (0,0) -- (1,0) node[right] {$u$};
      \draw[->] (0,0) -- (0,1) node[above] {$v$};
      \draw[scale=1,domain=0:1,smooth,variable=\x,blue] plot ({\x},{-(-1+\x)*(\x+0.25)/1});
      \draw[scale=1,domain=0:1,smooth,variable=\x,red]  plot ({\x},{\x});
                        \end{tikzpicture}
\end{document}

enter image description here

enter image description here

2
  • Here is an example.
    – user194703
    Commented Jan 20, 2020 at 16:50
  • @Schrödinger'scat I have seen but unable to get plot. May I request you to help for the problem. Commented Jan 20, 2020 at 16:52

1 Answer 1

2

This is really just a copy of this post.

\documentclass[border=3mm,tikz]{standalone}
\begin{document}
\begin{tikzpicture}[declare function={du(\u,\v)=\u*(1 - \u) - (a*\u*\v)/(\u + d);
    dv(\u,\v)=b*\v*(1 - \v/\u);
    a=1;b=0.2;d=0.25;
    },scale=2.5,>=stealth]
      \draw[->] (0,0) -- (1,0) node[right] {$u$};
      \draw[->] (0,0) -- (0,1) node[above] {$v$};
      \draw[scale=1,domain=0:1,smooth,variable=\x,blue] plot ({\x},{-(-a+\x)*(\x+d)/a});
      \draw[scale=1,domain=0:1,smooth,variable=\x,red]  plot ({\x},{\x});   
      \pgfmathsetmacro{\tmin}{0}
      \pgfmathsetmacro{\ustart}{0.2}
      \pgfmathsetmacro{\vstart}{0.8}
      \pgfmathsetmacro{\stept}{0.01}
      \pgfmathsetmacro{\nextt}{\tmin+\stept}
      \pgfmathsetmacro{\nextnextt}{\tmin+2*\stept}
      \pgfmathsetmacro{\tfin}{50}
      \xdef\lstX{(\ustart,\vstart)}
      \pgfmathsetmacro{\myu}{\ustart}
      \pgfmathsetmacro{\myv}{\vstart}
      \foreach \TT in {\nextt,\nextnextt,...,\tfin}
      {\pgfmathsetmacro{\myu}{\myu+du(\myu,\myv)*\stept}
      \pgfmathsetmacro{\myv}{\myv+dv(\myu,\myv)*\stept}
      \xdef\myu{\myu}
      \xdef\myv{\myv}
      \xdef\lstX{\lstX (\myu,\myv)}
      }
      \draw[blue,thick] plot[smooth] coordinates {\lstX};
      \draw ([xshift=-1ex,yshift=-1ex]current bounding box.south west)
       rectangle  ([xshift=1ex,yshift=1ex]current bounding box.north east);
\end{tikzpicture}
\end{document}

enter image description here

9
  • Thank you very much.I want to join my nulcline \draw[scale=1,domain=0:1,smooth,variable=\x,blue] plot ({\x},{-(-1+\x)*(\x+0.25)/1}); \draw[scale=1,domain=0:1,smooth,variable=\x,red] plot ({\x},{\x}); on the same figure.. How to do that? Commented Jan 20, 2020 at 17:47
  • @user1942348 I added them.
    – user194703
    Commented Jan 20, 2020 at 17:52
  • Thank you very much.... Commented Jan 20, 2020 at 17:53
  • 1
    @user1942348 Sorry, this is not what this site is for. You can always ask a new question, which is free of charge. But you should not use one question to place several additional requests. I have answered the original question. If I add another version of the box, then I will be trapped in an infinite loop with one additional request followed by another, something I am not willing to do.
    – user194703
    Commented Jan 20, 2020 at 18:07
  • 1
    @frougon Thanks! I think one could improve it quite a bit, but there will be always cases which aren't covered. So this is all to show that one may do this in principle with LaTeX, but in practice I think Mathematica will always win. (user121799 also used to mention the sources of their inspiration ;-)
    – user194703
    Commented Jan 21, 2020 at 0:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .