simplePendulum: The simple pendulum model

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/simplePendulum.R

Description

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

Usage

1
simplePendulum(t, y, parameters)

Arguments

t

The value of t, the independent variable, to evaluate the derivative at. Should be a numeric vector of length one.

y

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

parameters

The values of the parameters of the system. Should be a numeric vector prescribing the value of l.

Details

simplePendulum evaluates the derivative of the following ODE at the point (t, x, y):

dx/dt = y, dy/dt = -g sin(x)/l.

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

Value

Returns a list containing the values of the two derivatives at (t, x, y).

Author(s)

Michael J Grayling

See Also

ode

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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)
# 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)

Example output

Note: col has been reset as required
T: 0   Delta: 1.962   Discriminant: -7.848   Classification: CentreT: 0   Delta: -1.962   Discriminant: 7.848   Classification: Saddle

phaseR documentation built on Oct. 12, 2019, 9:05 a.m.