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 This functions serves as an interface to the three differentiation
37 functions present in GSL: gsl_diff_central, gsl_diff_backward and
38 gsl_diff_forward. To compute the derivative, the central method uses
39 values greater and smaller than the point at which the derivative is to
40 be evaluated, while backward and forward use only values smaller and
41 greater respectively. gsldiff() returns both the derivative and an
42 absolute error estimate. The default method is 'central', others can
43 be specified by passing an option.
44
45 Please check the GSL documentation for more information.
46
47 Usage:
48
49 ($d,$abserr) = gsldiff($function_ref,$x,{Method => $method});
50
51 Example:
52
53 #derivative using default method ('central')
54 ($d,$abserr) = gsldiff(\&myf,3.3);
55
56 #same as above with method set explicitly
57 ($d,$abserr) = gsldiff(\&myf,3.3,{Method => 'central'});
58
59 #using backward & forward methods
60 ($d,$abserr) = gsldiff(\&myf,3.3,{Method => 'backward'});
61 ($d,$abserr) = gsldiff(\&myf,3.3,{Method => 'forward'});
62
63 sub myf{
64 my ($x) = @_;
65 return exp($x);
66 }
67
69 Feedback is welcome. Log bugs in the PDL bug database (the database is
70 always linked from http://pdl.perl.org).
71
73 PDL
74
75 The GSL documentation is online at
76
77 http://sources.redhat.com/gsl/ref/gsl-ref_toc.html
78
80 This file copyright (C) 2003 Andres Jordan
81 <andresj@physics.rutgers.edu> All rights reserved. There is no
82 warranty. You are allowed to redistribute this software documentation
83 under certain conditions. For details, see the file COPYING in the PDL
84 distribution. If this file is separated from the PDL distribution, the
85 copyright notice should be included in the file.
86
87 The GSL differentiation routines were written by David Morrison.
88
90 diff_central
91 Signature: (double x(); double [o] res(); double [o] abserr(); SV* funcion)
92
93 info not available
94
95 diff_central does not process bad values. It will set the bad-value
96 flag of all output piddles if the flag is set for any of the input
97 piddles.
98
99 diff_backward
100 Signature: (double x(); double [o] res(); double [o] abserr(); SV* funcion)
101
102 info not available
103
104 diff_backward does not process bad values. It will set the bad-value
105 flag of all output piddles if the flag is set for any of the input
106 piddles.
107
108 diff_forward
109 Signature: (double x(); double [o] res(); double [o] abserr(); SV* funcion)
110
111 info not available
112
113 diff_forward does not process bad values. It will set the bad-value
114 flag of all output piddles if the flag is set for any of the input
115 piddles.
116
117
118
119perl v5.12.3 2011-03-31 DIFF(3)