# StreamPlot not working

I'm new to Mathematica and I'm trying to plot the directional field of the following differential equation:

$$\dfrac{\mathbb{d}W}{\mathbb{d}R} = \dfrac{-0.02W + 0.00002RW}{0.08R-0.001RW}$$

And I was expecting to acheive the following results:

So I tried to use StreamPlot in the following command:

StreamPlot[{1, (-0.02 W + 0.00002 R W)/(0.08 R - 0.001 R W)}, {R, 0, 3000}, {W, 0, 150}]


But It caused the following errors:

Power::infy: Infinite expression 1/0. encountered. >>
Infinity::indet: Indeterminate expression 0. ComplexInfinity encountered. >>
Power::infy: Infinite expression 1/0. encountered. >>
Infinity::indet: Indeterminate expression 0. ComplexInfinity encountered. >>


What am I doing wrong and how do I fix it?

• Notice when R==0 and W==0 your denominator==0. Try {R,1,3000}, {W,1,150} and your 1/0 errors go away. That still leaves other issues, like your {1,(-0.02W+0.00002R W)...} when none of the examples in the help pages for StreamPlot use a 1 the way you do. Maybe you want {(0.08 R - 0.001 R W), (-0.02 W + 0.00002 R W)} but it is difficult to tell.
– Bill
Jan 21, 2017 at 21:54

A couple tweaks improve the results.

1) @Rahul's myStreamPlot from here will fill in the streams nicely.

2) As @Bill writes, better to separate dW and dR in the plot command (otherwise the R direction will always have positive sign, which contradicts the predator-prey origin of the equations).

Together:

Options[myStreamPlot] = Options[StreamPlot];
myStreamPlot[f_, {x_, x0_, x1_}, {y_, y0_, y1_}, opts : OptionsPattern[]] :=
With[{a = OptionValue[AspectRatio]},
Show[StreamPlot[{1/(x1 - x0), a/(y1 - y0)} (f /. {x -> x0 + u (x1 - x0), y -> y0 + v/a (y1 - y0)})
, {u, 0, 1}, {v, 0, a}, opts] /. Arrow[pts_] :> Arrow[({x0, y0} + {x1 - x0, (y1 - y0)/a} #) & /@ pts],
PlotRange -> {{x0, x1}, {y0, y1}}]]

myStreamPlot[{(0.08 R - 0.001 R W), (-0.02 W + 0.00002 R W)}, {R, 0, 3000}, {W, 0, 150}]


• I don't know, it works for me on 11.0.1. Try a fresh kernel? Jan 22, 2017 at 0:00
• Thankx, I closed and reopened the program and tried again and it worked. Could you please add some explanation on how the code works, I'm a beginner in Mathematica . Jan 22, 2017 at 0:30
• Despite its name, myStreamPlot is not my work. To understand how it works, see the description by its author @Rahul here. Jan 22, 2017 at 1:14