1
subroutine dqc25f(f,a,b,omega,integr,nrmom,maxp1,ksave,result,
2
* abserr,neval,resabs,resasc,momcom,chebmo)
3
c***begin prologue dqc25f
4
c***date written 810101 (yymmdd)
5
c***revision date 830518 (yymmdd)
6
c***category no. h2a2a2
7
c***keywords integration rules for functions with cos or sin
8
c factor, clenshaw-curtis, gauss-kronrod
9
c***author piessens,robert,appl. math. & progr. div. - k.u.leuven
10
c de doncker,elise,appl. math. & progr. div. - k.u.leuven
11
c***purpose to compute the integral i=integral of f(x) over (a,b)
12
c where w(x) = cos(omega*x) or w(x)=sin(omega*x) and to
13
c compute j = integral of abs(f) over (a,b). for small value
14
c of omega or small intervals (a,b) the 15-point gauss-kronro
15
c rule is used. otherwise a generalized clenshaw-curtis
19
c integration rules for functions with cos or sin factor
20
c standard fortran subroutine
21
c double precision version
25
c f - double precision
26
c function subprogram defining the integrand
27
c function f(x). the actual name for f needs to
28
c be declared e x t e r n a l in the calling program.
30
c a - double precision
31
c lower limit of integration
33
c b - double precision
34
c upper limit of integration
36
c omega - double precision
37
c parameter in the weight function
40
c indicates which weight function is to be used
41
c integr = 1 w(x) = cos(omega*x)
42
c integr = 2 w(x) = sin(omega*x)
45
c the length of interval (a,b) is equal to the length
46
c of the original integration interval divided by
47
c 2**nrmom (we suppose that the routine is used in an
48
c adaptive integration process, otherwise set
49
c nrmom = 0). nrmom must be zero at the first call.
52
c gives an upper bound on the number of chebyshev
53
c moments which can be stored, i.e. for the
54
c intervals of lengths abs(bb-aa)*2**(-l),
55
c l = 0,1,2, ..., maxp1-2.
58
c key which is one when the moments for the
59
c current interval have been computed
62
c result - double precision
63
c approximation to the integral i
65
c abserr - double precision
66
c estimate of the modulus of the absolute
67
c error, which should equal or exceed abs(i-result)
70
c number of integrand evaluations
72
c resabs - double precision
73
c approximation to the integral j
75
c resasc - double precision
76
c approximation to the integral of abs(f-i/(b-a))
80
c for each interval length we need to compute the
81
c chebyshev moments. momcom counts the number of
82
c intervals for which these moments have already been
83
c computed. if nrmom.lt.momcom or ksave = 1, the
84
c chebyshev moments for the interval (a,b) have
85
c already been computed and stored, otherwise we
86
c compute them and we increase momcom.
88
c chebmo - double precision
89
c array of dimension at least (maxp1,25) containing
90
c the modified chebyshev moments for the first momcom
91
c momcom interval lengths
93
c ......................................................................
95
c***routines called d1mach,dgtsl,dqcheb,dqk15w,dqwgtf
96
c***end prologue dqc25f
98
double precision a,abserr,ac,an,an2,as,asap,ass,b,centr,chebmo,
99
* cheb12,cheb24,conc,cons,cospar,d,dabs,dcos,dsin,dqwgtf,d1,
100
* d1mach,d2,estc,ests,f,fval,hlgth,oflow,omega,parint,par2,par22,
101
* p2,p3,p4,resabs,resasc,resc12,resc24,ress12,ress24,result,
103
integer i,iers,integr,isym,j,k,ksave,m,momcom,neval,maxp1,
106
dimension chebmo(maxp1,25),cheb12(13),cheb24(25),d(25),d1(25),
107
* d2(25),fval(25),v(28),x(11)
111
c the vector x contains the values cos(k*pi/24)
112
c k = 1, ...,11, to be used for the chebyshev expansion of f
114
data x(1) / 0.9914448613 7381041114 4557526928 563d0 /
115
data x(2) / 0.9659258262 8906828674 9743199728 897d0 /
116
data x(3) / 0.9238795325 1128675612 8183189396 788d0 /
117
data x(4) / 0.8660254037 8443864676 3723170752 936d0 /
118
data x(5) / 0.7933533402 9123516457 9776961501 299d0 /
119
data x(6) / 0.7071067811 8654752440 0844362104 849d0 /
120
data x(7) / 0.6087614290 0872063941 6097542898 164d0 /
121
data x(8) / 0.5000000000 0000000000 0000000000 000d0 /
122
data x(9) / 0.3826834323 6508977172 8459984030 399d0 /
123
data x(10) / 0.2588190451 0252076234 8898837624 048d0 /
124
data x(11) / 0.1305261922 2005159154 8406227895 489d0 /
126
c list of major variables
127
c -----------------------
129
c centr - mid point of the integration interval
130
c hlgth - half-length of the integration interval
131
c fval - value of the function f at the points
132
c (b-a)*0.5*cos(k*pi/12) + (b+a)*0.5, k = 0, ..., 24
133
c cheb12 - coefficients of the chebyshev series expansion
134
c of degree 12, for the function f, in the
136
c cheb24 - coefficients of the chebyshev series expansion
137
c of degree 24, for the function f, in the
139
c resc12 - approximation to the integral of
140
c cos(0.5*(b-a)*omega*x)*f(0.5*(b-a)*x+0.5*(b+a))
141
c over (-1,+1), using the chebyshev series
142
c expansion of degree 12
143
c resc24 - approximation to the same integral, using the
144
c chebyshev series expansion of degree 24
145
c ress12 - the analogue of resc12 for the sine
146
c ress24 - the analogue of resc24 for the sine
149
c machine dependent constant
150
c --------------------------
152
c oflow is the largest positive magnitude.
154
c***first executable statement dqc25f
157
centr = 0.5d+00*(b+a)
158
hlgth = 0.5d+00*(b-a)
161
c compute the integral using the 15-point gauss-kronrod
162
c formula if the value of the parameter in the integrand
165
if(dabs(parint).gt.0.2d+01) go to 10
166
call dqk15w(f,dqwgtf,omega,p2,p3,p4,integr,a,b,result,
167
* abserr,resabs,resasc)
171
c compute the integral using the generalized clenshaw-
174
10 conc = hlgth*dcos(centr*omega)
175
cons = hlgth*dsin(centr*omega)
179
c check whether the chebyshev moments for this interval
180
c have already been computed.
182
if(nrmom.lt.momcom.or.ksave.eq.1) go to 120
184
c compute a new set of chebyshev moments.
189
sinpar = dsin(parint)
190
cospar = dcos(parint)
192
c compute the chebyshev moments with respect to cosine.
194
v(1) = 0.2d+01*sinpar/parint
195
v(2) = (0.8d+01*cospar+(par2+par2-0.8d+01)*sinpar/parint)/par2
196
v(3) = (0.32d+02*(par2-0.12d+02)*cospar+(0.2d+01*
197
* ((par2-0.80d+02)*par2+0.192d+03)*sinpar)/parint)/(par2*par2)
199
as = 0.24d+02*parint*sinpar
200
if(dabs(parint).gt.0.24d+02) go to 30
202
c compute the chebyshev moments as the solutions of a
203
c boundary value problem with 1 initial value (v(3)) and 1
204
c end value (computed using an asymptotic formula).
211
d(k) = -0.2d+01*(an2-0.4d+01)*(par22-an2-an2)
212
d2(k) = (an-0.1d+01)*(an-0.2d+01)*par2
213
d1(k+1) = (an+0.3d+01)*(an+0.4d+01)*par2
214
v(k+3) = as-(an2-0.4d+01)*ac
218
d(noequ) = -0.2d+01*(an2-0.4d+01)*(par22-an2-an2)
219
v(noequ+3) = as-(an2-0.4d+01)*ac
220
v(4) = v(4)-0.56d+02*par2*v(3)
222
asap = (((((0.210d+03*par2-0.1d+01)*cospar-(0.105d+03*par2
223
* -0.63d+02)*ass)/an2-(0.1d+01-0.15d+02*par2)*cospar
224
* +0.15d+02*ass)/an2-cospar+0.3d+01*ass)/an2-cospar)/an2
225
v(noequ+3) = v(noequ+3)-0.2d+01*asap*par2*(an-0.1d+01)*
228
c solve the tridiagonal system by means of gaussian
229
c elimination with partial pivoting.
231
c*** call to dgtsl must be replaced by call to
232
c*** double precision version of linpack routine sgtsl
234
call dgtsl(noequ,d1,d,d2,v(4),iers)
237
c compute the chebyshev moments by means of forward
243
v(i) = ((an2-0.4d+01)*(0.2d+01*(par22-an2-an2)*v(i-1)-ac)
244
* +as-par2*(an+0.1d+01)*(an+0.2d+01)*v(i-2))/
245
* (par2*(an-0.1d+01)*(an-0.2d+01))
249
chebmo(m,2*j-1) = v(j)
252
c compute the chebyshev moments with respect to sine.
254
v(1) = 0.2d+01*(sinpar-parint*cospar)/par2
255
v(2) = (0.18d+02-0.48d+02/par2)*sinpar/par2
256
* +(-0.2d+01+0.48d+02/par2)*cospar/parint
257
ac = -0.24d+02*parint*cospar
259
if(dabs(parint).gt.0.24d+02) go to 80
261
c compute the chebyshev moments as the solutions of a boundary
262
c value problem with 1 initial value (v(2)) and 1 end value
263
c (computed using an asymptotic formula).
268
d(k) = -0.2d+01*(an2-0.4d+01)*(par22-an2-an2)
269
d2(k) = (an-0.1d+01)*(an-0.2d+01)*par2
270
d1(k+1) = (an+0.3d+01)*(an+0.4d+01)*par2
271
v(k+2) = ac+(an2-0.4d+01)*as
275
d(noequ) = -0.2d+01*(an2-0.4d+01)*(par22-an2-an2)
276
v(noequ+2) = ac+(an2-0.4d+01)*as
277
v(3) = v(3)-0.42d+02*par2*v(2)
279
asap = (((((0.105d+03*par2-0.63d+02)*ass+(0.210d+03*par2
280
* -0.1d+01)*sinpar)/an2+(0.15d+02*par2-0.1d+01)*sinpar-
281
* 0.15d+02*ass)/an2-0.3d+01*ass-sinpar)/an2-sinpar)/an2
282
v(noequ+2) = v(noequ+2)-0.2d+01*asap*par2*(an-0.1d+01)
285
c solve the tridiagonal system by means of gaussian
286
c elimination with partial pivoting.
288
c*** call to dgtsl must be replaced by call to
289
c*** double precision version of linpack routine sgtsl
291
call dgtsl(noequ,d1,d,d2,v(3),iers)
294
c compute the chebyshev moments by means of forward recursion.
299
v(i) = ((an2-0.4d+01)*(0.2d+01*(par22-an2-an2)*v(i-1)+as)
300
* +ac-par2*(an+0.1d+01)*(an+0.2d+01)*v(i-2))
301
* /(par2*(an-0.1d+01)*(an-0.2d+01))
307
120 if (nrmom.lt.momcom) m = nrmom+1
308
if (momcom.lt.(maxp1-1).and.nrmom.ge.momcom) momcom = momcom+1
310
c compute the coefficients of the chebyshev expansions
311
c of degrees 12 and 24 of the function f.
313
fval(1) = 0.5d+00*f(centr+hlgth)
315
fval(25) = 0.5d+00*f(centr-hlgth)
318
fval(i) = f(hlgth*x(i-1)+centr)
319
fval(isym) = f(centr-hlgth*x(i-1))
321
call dqcheb(x,fval,cheb12,cheb24)
323
c compute the integral and error estimates.
325
resc12 = cheb12(13)*chebmo(m,13)
329
resc12 = resc12+cheb12(k)*chebmo(m,k)
330
ress12 = ress12+cheb12(k+1)*chebmo(m,k+1)
333
resc24 = cheb24(25)*chebmo(m,25)
335
resabs = dabs(cheb24(25))
338
resc24 = resc24+cheb24(k)*chebmo(m,k)
339
ress24 = ress24+cheb24(k+1)*chebmo(m,k+1)
340
resabs = dabs(cheb24(k))+dabs(cheb24(k+1))
343
estc = dabs(resc24-resc12)
344
ests = dabs(ress24-ress12)
345
resabs = resabs*dabs(hlgth)
346
if(integr.eq.2) go to 160
347
result = conc*resc24-cons*ress24
348
abserr = dabs(conc*estc)+dabs(cons*ests)
350
160 result = conc*ress24+cons*resc24
351
abserr = dabs(conc*ests)+dabs(cons*estc)