For a one-dimensional autonomous ODE, it plots the phase portrait, i.e., the derivative against the dependent variable. In addition, along the dependent variable axis it plots arrows pointing in the direction of dependent variable change with increasing value of the independent variable. From this stability of equilibrium points (i.e., locations where the horizontal axis is crossed) can be determined.
phasePortrait(deriv, ylim, ystep = 0.01, parameters = NULL,
points = 10, frac = 0.75, arrow.head = 0.075, col = "black",
add.grid = TRUE, state.names = "y", xlab = state.names,
ylab = paste0("d", state.names), ...)
Returns a list with the following components:
As per input.
As per input.
As per input, but with possible editing if a
character
vector
of the wrong
length
was supplied.
As per input.
A numeric
vector
containing
the value of the derivative at each evaluated point.
As per input.
As per input.
As per input.
As per input.
A numeric
vector
containing
the values of the dependent variable for which the derivative was evaluated.
As per input.
As per input.
As per input.
A function computing the derivative at a point for the ODE
system to be analysed. Discussion of the required structure of these
functions can be found in the package vignette, or in the help file for the
function ode
.
Sets the limits of the dependent variable for which the
derivative should be computed and plotted. Should be a
numeric
vector
of
length
two.
Sets the step length of the dependent variable vector for which
derivatives are computed and plotted. Decreasing ystep
makes the
resulting plot more accurate, but comes at a small cost to computation time.
Defaults to 0.01
.
Parameters of the ODE system, to be passed to deriv
.
Supplied as a numeric
vector
; the
order of the parameters can be found from the deriv
file. Defaults to
NULL
.
Sets the density at which arrows are plotted along the
horizontal axis; points
arrows will be plotted. Fine tuning here, by
shifting points
up and down, allows for the creation of more
aesthetically pleasing plots. Defaults to 10
.
Sets the fraction of the theoretical maximum length line
segments can take without overlapping, that they actually attain. Fine
tuning here assists the creation of aesthetically pleasing plots. Defaults
to 0.75
.
Sets the length of the arrow heads. Passed to
arrows
. Defaults to 0.075
.
Sets the colour of the line in the plot, as well as the arrows.
Should be a character
vector
of length
one. Will be reset
accordingly if it is of the wrong length
. Defaults to
"black"
.
Logical. If TRUE
, a grid is added to the plot.
Defaults to TRUE
.
The state names for ode
functions
that do not use positional states.
Label for the x-axis of the resulting plot.
Label for the y-axis of the resulting plot.
Additional arguments to be passed to either plot or arrows.
Michael J Grayling
# A one-dimensional autonomous ODE system, example2.
example2_phasePortrait <- phasePortrait(example2,
ylim = c(-0.5, 2.5),
points = 10,
frac = 0.5)
Run the code above in your browser using DataLab