1DIFF(3) User Contributed Perl Documentation DIFF(3)
2
3
4
6 PDL::GSL::DIFF - PDL interface to numerical differentiation routines in
7 GSL
8
10 This is an interface to the numerical differentiation package present
11 in the GNU Scientific Library.
12
14 use PDL;
15 use PDL::GSL::DIFF;
16
17 my $x0 = 3.3;
18
19 my @res = gsldiff(\&myfunction,$x0);
20 # same as above:
21 @res = gsldiff(\&myfunction,$x0,{Method => 'central'});
22
23 # use only values greater than $x0 to get the derivative
24 @res = gsldiff(\&myfunction,$x0,{Method => 'forward'});
25
26 # use only values smaller than $x0 to get the derivative
27 @res = gsldiff(\&myfunction,$x0,{Method => 'backward'});
28
29 sub myfunction{
30 my ($x) = @_;
31 return $x**2;
32 }
33
35 gsldiff()
36
37 This functions serves as an interface to the three differentiation
38 functions present in GSL: gsl_diff_central, gsl_diff_backward and
39 gsl_diff_forward. To compute the derivative, the central method uses
40 values greater and smaller than the point at which the derivative is to
41 be evaluated, while backward and forward use only values smaller and
42 greater respectively. gsldiff() returns both the derivative and an
43 absolute error estimate. The default method is 'central', others can
44 be specified by passing an option.
45
46 Please check the GSL documentation for more information.
47
48 Usage:
49
50 ($d,$abserr) = gsldiff($function_ref,$x,{Method => $method});
51
52 Example:
53
54 #derivative using default method ('central')
55 ($d,$abserr) = gsldiff(\&myf,3.3);
56
57 #same as above with method set explicitly
58 ($d,$abserr) = gsldiff(\&myf,3.3,{Method => 'central'});
59
60 #using backward & forward methods
61 ($d,$abserr) = gsldiff(\&myf,3.3,{Method => 'backward'});
62 ($d,$abserr) = gsldiff(\&myf,3.3,{Method => 'forward'});
63
64 sub myf{
65 my ($x) = @_;
66 return exp($x);
67 }
68
70 Feedback is welcome. Log bugs in the PDL bug database (the database is
71 always linked from http://pdl.perl.org).
72
74 PDL
75
76 The GSL documentation is online at
77
78 http://sources.redhat.com/gsl/ref/gsl-ref_toc.html
79
81 This file copyright (C) 2003 Andres Jordan <andresj@physics.rut‐
82 gers.edu> All rights reserved. There is no warranty. You are allowed to
83 redistribute this software documentation under certain conditions. For
84 details, see the file COPYING in the PDL distribution. If this file is
85 separated from the PDL distribution, the copyright notice should be
86 included in the file.
87
88 The GSL differentiation routines were written by David Morrison.
89
91 diff_central
92
93 Signature: (double x(); double [o] res(); double [o] abserr(); SV* funcion)
94
95 info not available
96
97 diff_backward
98
99 Signature: (double x(); double [o] res(); double [o] abserr(); SV* funcion)
100
101 info not available
102
103 diff_forward
104
105 Signature: (double x(); double [o] res(); double [o] abserr(); SV* funcion)
106
107 info not available
108
109
110
111perl v5.8.8 2006-12-02 DIFF(3)