1Spline(3)             User Contributed Perl Documentation            Spline(3)
2
3
4

NAME

6           Math::Spline  - Cubic Spline Interpolation of data
7

SYNOPSIS

9           require Math::Spline;
10           $spline=new Math::Spline(\@x,\@y)
11           $y_interp=$spline->evaluate($x);
12
13           use Math::Spline qw(spline linsearch binsearch);
14           use Math::Derivative qw(Derivative2);
15           @y2=Derivative2(\@x,\@y);
16           $index=binsearch(\@x,$x);
17           $index=linsearch(\@x,$x,$index);
18           $y_interp=spline(\@x,\@y,\@y2,$index,$x);
19

DESCRIPTION

21       This package provides cubic spline interpolation of numeric data. The
22       data is passed as references to two arrays containing the x and y
23       ordinates. It may be used as an exporter of the numerical functions or,
24       more easily as a class module.
25
26       The Math::Spline class constructor new takes references to the arrays
27       of x and y ordinates of the data. An interpolation is performed using
28       the evaluate method, which, when given an x ordinate returns the
29       interpolate y ordinate at that value.
30
31       The spline function takes as arguments references to the x and y
32       ordinate array, a reference to the 2nd derivatives (calculated using
33       Derivative2, the low index of the interval in which to interpolate and
34       the x ordinate in that interval. Returned is the interpolated y
35       ordinate. Two functions are provided to look up the appropriate index
36       in the array of x data. For random calls binsearch can be used - give a
37       reference to the x ordinates and the x loopup value it returns the low
38       index of the interval in the data in which the value lies. Where the
39       lookups are strictly in ascending sequence (e.g. if interpolating to
40       produce a higher resolution data set to draw a curve) the linsearch
41       function may more efficiently be used. It performs like binsearch, but
42       requires a third argument being the previous index value, which is
43       incremented if necessary.
44

NOTE

46       requires Math::Derivative module
47

EXAMPLE

49           require Math::Spline;
50           my @x=(1,3,8,10);
51           my @y=(1,2,3,4);
52           $spline=new Math::Spline(\@x,\@y);
53           print $spline->evaluate(5)."\n";
54
55       produces the output
56
57       2.44
58

HISTORY

60       $Log: Spline.pm,v $ Revision 1.1  1995/12/26 17:28:17  willijar Initial
61       revision
62

BUGS

64       Bug reports or constructive comments are welcome.
65

AUTHOR

67       John A.R. Williams <J.A.R.Williams@aston.ac.uk>
68

SEE ALSO

70       "Numerical Recipies: The Art of Scientific Computing" W.H. Press, B.P.
71       Flannery, S.A. Teukolsky, W.T. Vetterling.  Cambridge University Press.
72       ISBN 0 521 30811 9.
73
74
75
76perl v5.12.0                      1995-12-26                         Spline(3)
Impressum