Learn R Programming

phaseR (version 2.0)

simplePendulum: The Simple Pendulum Model

Description

The derivative function of the simple pendulum model, an example of a two-dimensional autonomous ODE system.

Usage

simplePendulum(t, y, parameters)

Arguments

t

The value of , the independent variable, to evaluate the derivative at. Should be a single number.

y

The values of and , the dependent variables, to evaluate the derivative at. Should be a vector of length two.

parameters

The values of the parameters of the system. Should be a single number prescribing the value of .

Value

Returns a list containing the values of the two derivatives at .

Details

simplePendulum evaluates the derivative of the following ODE at the point :

Its format is designed to be compatible with ode from the deSolve package.

See Also

ode

Examples

Run this code
# NOT RUN {
# Plot the velocity field, nullclines and several trajectories
simplePendulum.flowField   <- flowField(simplePendulum,
                                        xlim = c(-7, 7),
                                        ylim = c(-7, 7),
                                        parameters = 5,
                                        points = 19,
                                        add = FALSE)
y0                         <- matrix(c(0, 1, 0, 4, -6, 1, 5, 0.5, 0, -3),
                                     5, 2, byrow = TRUE)
simplePendulum.nullclines  <- nullclines(simplePendulum,
                                         xlim = c(-7, 7),
                                         ylim = c(-7, 7),
                                         parameters = 5,
                                         points = 500)
simplePendulum.trajectory  <- trajectory(simplePendulum,
                                         y0 = y0,
                                         tlim = c(0, 10),
                                         parameters = 5)
simplePendulum.manifolds   <- drawManifolds(simplePendulum,
                                            y0 = c(pi, 0),
                                            parameters = 5,
                                            tend = 1000,
                                            col = c("green", "red"),
                                            add.legend = TRUE)
# Determine the stability of two equilibrium points
simplePendulum.stability.1 <- stability(simplePendulum,
                                        ystar = c(0, 0),
                                        parameters = 5)
simplePendulum.stability.2 <- stability(simplePendulum,
                                        ystar = c(pi, 0),
                                        parameters = 5)
# }

Run the code above in your browser using DataLab