GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
qagp.f
Go to the documentation of this file.
1 subroutine qagp(f,a,b,npts2,points,epsabs,epsrel,result,abserr,
2 * neval,ier,leniw,lenw,last,iwork,work)
3c***begin prologue qagp
4c***date written 800101 (yymmdd)
5c***revision date 830518 (yymmdd)
6c***category no. h2a2a1
7c***keywords automatic integrator, general-purpose,
8c singularities at user specified points,
9c extrapolation, globally adaptive
10c***author piessens,robert,appl. math. & progr. div - k.u.leuven
11c de doncker,elise,appl. math. & progr. div. - k.u.leuven
12c***purpose the routine calculates an approximation result to a given
13c definite integral i = integral of f over (a,b),
14c hopefully satisfying following claim for accuracy
15c break points of the integration interval, where local
16c difficulties of the integrand may occur(e.g. singularities,
17c discontinuities), are provided by the user.
18c***description
19c
20c computation of a definite integral
21c standard fortran subroutine
22c real version
23c
24c parameters
25c on entry
26c f - subroutine f(x,ierr,result) defining the integrand
27c function f(x). the actual name for f needs to be
28c declared e x t e r n a l in the driver program.
29c
30c a - real
31c lower limit of integration
32c
33c b - real
34c upper limit of integration
35c
36c npts2 - integer
37c number equal to two more than the number of
38c user-supplied break points within the integration
39c range, npts.ge.2.
40c if npts2.lt.2, the routine will end with ier = 6.
41c
42c points - real
43c vector of dimension npts2, the first (npts2-2)
44c elements of which are the user provided break
45c points. if these points do not constitute an
46c ascending sequence there will be an automatic
47c sorting.
48c
49c epsabs - real
50c absolute accuracy requested
51c epsrel - real
52c relative accuracy requested
53c if epsabs.le.0
54c and epsrel.lt.max(50*rel.mach.acc.,0.5d-28),
55c the routine will end with ier = 6.
56c
57c on return
58c result - real
59c approximation to the integral
60c
61c abserr - real
62c estimate of the modulus of the absolute error,
63c which should equal or exceed abs(i-result)
64c
65c neval - integer
66c number of integrand evaluations
67c
68c ier - integer
69c ier = 0 normal and reliable termination of the
70c routine. it is assumed that the requested
71c accuracy has been achieved.
72c ier.gt.0 abnormal termination of the routine.
73c the estimates for integral and error are
74c less reliable. it is assumed that the
75c requested accuracy has not been achieved.
76c error messages
77c ier = 1 maximum number of subdivisions allowed
78c has been achieved. one can allow more
79c subdivisions by increasing the value of
80c limit (and taking the according dimension
81c adjustments into account). however, if
82c this yields no improvement it is advised
83c to analyze the integrand in order to
84c determine the integration difficulties. if
85c the position of a local difficulty can be
86c determined (i.e. singularity,
87c discontinuity within the interval), it
88c should be supplied to the routine as an
89c element of the vector points. if necessary
90c an appropriate special-purpose integrator
91c must be used, which is designed for
92c handling the type of difficulty involved.
93c = 2 the occurrence of roundoff error is
94c detected, which prevents the requested
95c tolerance from being achieved.
96c the error may be under-estimated.
97c = 3 extremely bad integrand behaviour occurs
98c at some points of the integration
99c interval.
100c = 4 the algorithm does not converge.
101c roundoff error is detected in the
102c extrapolation table.
103c it is presumed that the requested
104c tolerance cannot be achieved, and that
105c the returned result is the best which
106c can be obtained.
107c = 5 the integral is probably divergent, or
108c slowly convergent. it must be noted that
109c divergence can occur with any other value
110c of ier.gt.0.
111c = 6 the input is invalid because
112c npts2.lt.2 or
113c break points are specified outside
114c the integration range or
115c (epsabs.le.0 and
116c epsrel.lt.max(50*rel.mach.acc.,0.5d-28))
117c result, abserr, neval, last are set to
118c zero. exept when leniw or lenw or npts2 is
119c invalid, iwork(1), iwork(limit+1),
120c work(limit*2+1) and work(limit*3+1)
121c are set to zero.
122c work(1) is set to a and work(limit+1)
123c to b (where limit = (leniw-npts2)/2).
124c
125c dimensioning parameters
126c leniw - integer
127c dimensioning parameter for iwork
128c leniw determines limit = (leniw-npts2)/2,
129c which is the maximum number of subintervals in the
130c partition of the given integration interval (a,b),
131c leniw.ge.(3*npts2-2).
132c if leniw.lt.(3*npts2-2), the routine will end with
133c ier = 6.
134c
135c lenw - integer
136c dimensioning parameter for work
137c lenw must be at least leniw*2-npts2.
138c if lenw.lt.leniw*2-npts2, the routine will end
139c with ier = 6.
140c
141c last - integer
142c on return, last equals the number of subintervals
143c produced in the subdivision process, which
144c determines the number of significant elements
145c actually in the work arrays.
146c
147c work arrays
148c iwork - integer
149c vector of dimension at least leniw. on return,
150c the first k elements of which contain
151c pointers to the error estimates over the
152c subintervals, such that work(limit*3+iwork(1)),...,
153c work(limit*3+iwork(k)) form a decreasing
154c sequence, with k = last if last.le.(limit/2+2), and
155c k = limit+1-last otherwise
156c iwork(limit+1), ...,iwork(limit+last) contain the
157c subdivision levels of the subintervals, i.e.
158c if (aa,bb) is a subinterval of (p1,p2)
159c where p1 as well as p2 is a user-provided
160c break point or integration limit, then (aa,bb) has
161c level l if abs(bb-aa) = abs(p2-p1)*2**(-l),
162c iwork(limit*2+1), ..., iwork(limit*2+npts2) have
163c no significance for the user,
164c note that limit = (leniw-npts2)/2.
165c
166c work - real
167c vector of dimension at least lenw
168c on return
169c work(1), ..., work(last) contain the left
170c end points of the subintervals in the
171c partition of (a,b),
172c work(limit+1), ..., work(limit+last) contain
173c the right end points,
174c work(limit*2+1), ..., work(limit*2+last) contain
175c the integral approximations over the subintervals,
176c work(limit*3+1), ..., work(limit*3+last)
177c contain the corresponding error estimates,
178c work(limit*4+1), ..., work(limit*4+npts2)
179c contain the integration limits and the
180c break points sorted in an ascending sequence.
181c note that limit = (leniw-npts2)/2.
182c
183c***references (none)
184c***routines called qagpe,xerror
185c***end prologue qagp
186c
187 real a,abserr,b,epsabs,epsrel,points,result,work
188 integer ier,iwork,leniw,lenw,limit,lvl,l1,l2,l3,neval,npts2
189c
190 dimension iwork(leniw),points(npts2),work(lenw)
191c
192 external f
193c
194c check validity of limit and lenw.
195c
196c***first executable statement qagp
197 ier = 6
198 neval = 0
199 last = 0
200 result = 0.0e+00
201 abserr = 0.0e+00
202 if(leniw.lt.(3*npts2-2).or.lenw.lt.(leniw*2-npts2).or.npts2.lt.2)
203 * go to 10
204c
205c prepare call for qagpe.
206c
207 limit = (leniw-npts2)/2
208 l1 = limit+1
209 l2 = limit+l1
210 l3 = limit+l2
211 l4 = limit+l3
212c
213 call qagpe(f,a,b,npts2,points,epsabs,epsrel,limit,result,abserr,
214 * neval,ier,work(1),work(l1),work(l2),work(l3),work(l4),
215 * iwork(1),iwork(l1),iwork(l2),last)
216c
217c call error handler if necessary.
218c
219 lvl = 0
22010 if(ier.eq.6) lvl = 1
221 if(ier.ne.0) call xerror('abnormal return from qagp',26,ier,lvl)
222 return
223 end
subroutine qagp(f, a, b, npts2, points, epsabs, epsrel, result, abserr, neval, ier, leniw, lenw, last, iwork, work)
Definition qagp.f:3
subroutine qagpe(f, a, b, npts2, points, epsabs, epsrel, limit, result, abserr, neval, ier, alist, blist, rlist, elist, pts, iord, level, ndin, last)
Definition qagpe.f:4
subroutine xerror(messg, nmessg, nerr, level)
Definition xerror.f:2