nag_ode_ivp_rk_reset_tend (d02pwc) (PDF version)
d02 Chapter Contents
d02 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_ode_ivp_rk_reset_tend (d02pwc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_ode_ivp_rk_reset_tend (d02pwc) is a function to reset the end-point in an integration performed by nag_ode_ivp_rk_onestep (d02pdc).

2  Specification

#include <nag.h>
#include <nagd02.h>
void  nag_ode_ivp_rk_reset_tend (double tend_new, Nag_ODE_RK *opt, NagError *fail)

3  Description

nag_ode_ivp_rk_reset_tend (d02pwc) and its associated functions (nag_ode_ivp_rk_setup (d02pvc), nag_ode_ivp_rk_onestep (d02pdc), nag_ode_ivp_rk_interp (d02pxc), nag_ode_ivp_rk_errass (d02pzc)) solve the initial value problem for a first order system of ordinary differential equations. The functions, based on Runge–Kutta methods and derived from RKSUITE (Brankin et al. (1991)) integrate
y = f t,y  given  y t 0 = y 0
where y  is the vector of n  solution components and t  is the independent variable.
This function is used to reset the final value of the independent variable, t f  when the integration is already underway. It can be used to extend or reduce the range of integration. The new value must be beyond the current value of the independent variable (as returned in tnow by nag_ode_ivp_rk_onestep (d02pdc)) in the current direction of integration. It is much more efficient to use nag_ode_ivp_rk_reset_tend (d02pwc) for this purpose than to use nag_ode_ivp_rk_setup (d02pvc) which involves the overhead of a complete restart of the integration.
If you want to change the direction of integration then you must restart by a call to nag_ode_ivp_rk_setup (d02pvc).

4  References

Brankin R W, Gladwell I and Shampine L F (1991) RKSUITE: A suite of Runge–Kutta codes for the initial value problems for ODEs SoftReport 91-S1 Southern Methodist University

5  Arguments

1:     tend_newdoubleInput
On entry: the new value for t f
Constraint: sign tend_new-tnow = sign tend-tstart , where tstart and tend are as supplied in the previous call to nag_ode_ivp_rk_setup (d02pvc) and tnow is returned by the preceding call to nag_ode_ivp_rk_onestep (d02pdc). tend must be distinguishable from tnow for the method and the precision of the machine being used.
2:     optNag_ODE_RK *Input/Output
On entry: the structure of type Nag_ODE_RK as output from nag_ode_ivp_rk_onestep (d02pdc). You must not change this structure.
On exit: opt is suitably modified to reset the end-point.
3:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_MEMORY_FREED
Internally allocated memory has been freed by a call to nag_ode_ivp_rk_free (d02ppc) without a subsequent call to the setup function nag_ode_ivp_rk_setup (d02pvc).
NE_MISSING_CALL
Previous call to nag_ode_ivp_rk_onestep (d02pdc) has not been made, hence nag_ode_ivp_rk_reset_tend (d02pwc) must not be called.
NE_PREV_CALL
The previous call to a function had resulted in a severe error. You must call nag_ode_ivp_rk_setup (d02pvc) to start another problem.
NE_PREV_CALL_INI
The previous call to the function nag_ode_ivp_rk_onestep (d02pdc) had resulted in a severe error. You must call nag_ode_ivp_rk_setup (d02pvc) to start another problem.
NE_RK_DIRECTION_NEG
Integration is proceeding in the negative direction with the current value for the independent variable t being value. However tend_new has been set to value. tend_new must be less than t.
NE_RK_DIRECTION_POS
Integration is proceeding in the positive direction with the current value for the independent variable t being value. However tend_new has been set to value. tend_new must be greater than t.
NE_RK_INVALID_CALL
The function to be called as specified in the setup function nag_ode_ivp_rk_setup (d02pvc) was nag_ode_ivp_rk_range (d02pcc). However the actual call was made to nag_ode_ivp_rk_reset_tend (d02pwc). This is not permitted.
NE_RK_STEP
The current value of the independent variable t is value. The tend_new that is supplied has abstend_new-t = value. For the method and the precision of the computer being used, this difference must be at least value.

7  Accuracy

Not applicable.

8  Further Comments

None.

9  Example

We integrate a two body problem. The equations for the coordinates x t , y t  of one body as functions of time t  in a suitable frame of reference are
x = -x r 3 y = -y r 3 , r = x 2 + y 2 .
The intial conditions
x 0 = 1 - ε , x 0 = 0 y 0 = 0 , y 0 = 1+ε 1-ε
lead to elliptic motion with 0 < ε < 1 . We select ε=0.7  and repose as
y 1 = y 2 y 2 = y 4 y 3 = - y 1 r 3 y 4 = - y 1 r 3
over the range 0,6π . We use relative error control with threshold values of 1.0e−10  for each solution component and compute the solution at intervals of length π  across the range using nag_ode_ivp_rk_reset_tend (d02pwc) to reset the end of the integration range. We use a high order Runge–Kutta method (method=Nag_RK_7_8) with tolerances tol = 1.0e−4  and tol = 1.0e−5  in turn so that we may compare the solutions. The value of π  is obtained by using nag_pi (X01AAC).

9.1  Program Text

Program Text (d02pwce.c)

9.2  Program Data

None.

9.3  Program Results

Program Results (d02pwce.r)


nag_ode_ivp_rk_reset_tend (d02pwc) (PDF version)
d02 Chapter Contents
d02 Chapter Introduction
NAG C Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012