HAVSIN

The HAVSIN general subroutine evaluates a haversine function.

Use

Called By

Any user-written subroutine

Prerequisites

None

Calling Sequence

CALL HAVSIN (x, x0, h0, x1, h1, iord, value, errflg)

Input Arguments

 
h0
A double-precision variable that specifies the value of the function before the step (x £ x0).
h1
A double-precision variable that specifies the value of the function after the step (x x1).
iord
An integer variable that defines the order of the derivative that HAVSIN is to return. The order is usually zero, but it can be one or two.
x
A double-precision variable that specifies the independent variable.
x0
A double-precision variable that specifies the x value at which the haversine function begins.
x1
A double-precision variable that specifies the value at which the haversine function ends.

Output Arguments

 
errflg
A logical (true or false) variable that HAVSIN returns to the calling subroutine. If HAVSIN detects an error in the subroutine call statement, it sets errflg to true before it returns errflg to the calling subroutine.
value
A double-precision value the subroutine returns. If iord equals zero, value is the function evaluated at x. If iord equals one, value is the first derivative of F(x) with respect to the independent variable x. If iord equals two, value is the second derivative of F(x) with respect to the independent variable x. Value is:

Extended Definition

The HAVSIN general subroutine evaluates a haversine function. Figure 1 below illustrates the haversine function.
The value x is the independent variable, h0 and h1 are the initial and final values of the haversine function. The following equation defines HAVSIN:

 
Caution:  
The value x1 must not equal x0. Equal values of x1 and x0 imply a sharp step, which HAVSIN cannot fit.
At x0 and x1, the second derivatives of the haversine function do not match the second derivatives of the constant regions. This discontinuity increases as the values for x1 and x0 become closer (that is, as the haversine becomes sharper). Because of the discontinuity, integration problems can arise if the haversine is sharp.
The STEP general subroutine (see STEP) is an alternative to HAVSIN.