~ubuntu-branches/ubuntu/karmic/python-scipy/karmic

« back to all changes in this revision

Viewing changes to Lib/integrate/quadpack/dqk51.f

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T. Chen (new)
  • Date: 2005-03-16 02:15:29 UTC
  • Revision ID: james.westby@ubuntu.com-20050316021529-xrjlowsejs0cijig
Tags: upstream-0.3.2
ImportĀ upstreamĀ versionĀ 0.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
      subroutine dqk51(f,a,b,result,abserr,resabs,resasc)
 
2
c***begin prologue  dqk51
 
3
c***date written   800101   (yymmdd)
 
4
c***revision date  830518   (yymmdd)
 
5
c***category no.  h2a1a2
 
6
c***keywords  51-point gauss-kronrod rules
 
7
c***author  piessens,robert,appl. math. & progr. div. - k.u.leuven
 
8
c           de doncker,elise,appl. math & progr. div. - k.u.leuven
 
9
c***purpose  to compute i = integral of f over (a,b) with error
 
10
c                           estimate
 
11
c                       j = integral of abs(f) over (a,b)
 
12
c***description
 
13
c
 
14
c           integration rules
 
15
c           standard fortran subroutine
 
16
c           double precision version
 
17
c
 
18
c           parameters
 
19
c            on entry
 
20
c              f      - double precision
 
21
c                       function subroutine defining the integrand
 
22
c                       function f(x). the actual name for f needs to be
 
23
c                       declared e x t e r n a l in the calling program.
 
24
c
 
25
c              a      - double precision
 
26
c                       lower limit of integration
 
27
c
 
28
c              b      - double precision
 
29
c                       upper limit of integration
 
30
c
 
31
c            on return
 
32
c              result - double precision
 
33
c                       approximation to the integral i
 
34
c                       result is computed by applying the 51-point
 
35
c                       kronrod rule (resk) obtained by optimal addition
 
36
c                       of abscissae to the 25-point gauss rule (resg).
 
37
c
 
38
c              abserr - double precision
 
39
c                       estimate of the modulus of the absolute error,
 
40
c                       which should not exceed abs(i-result)
 
41
c
 
42
c              resabs - double precision
 
43
c                       approximation to the integral j
 
44
c
 
45
c              resasc - double precision
 
46
c                       approximation to the integral of abs(f-i/(b-a))
 
47
c                       over (a,b)
 
48
c
 
49
c***references  (none)
 
50
c***routines called  d1mach
 
51
c***end prologue  dqk51
 
52
c
 
53
      double precision a,absc,abserr,b,centr,dabs,dhlgth,dmax1,dmin1,
 
54
     *  d1mach,epmach,f,fc,fsum,fval1,fval2,fv1,fv2,hlgth,resabs,resasc,
 
55
     *  resg,resk,reskh,result,uflow,wg,wgk,xgk
 
56
      integer j,jtw,jtwm1
 
57
      external f
 
58
c
 
59
      dimension fv1(25),fv2(25),xgk(26),wgk(26),wg(13)
 
60
c
 
61
c           the abscissae and weights are given for the interval (-1,1).
 
62
c           because of symmetry only the positive abscissae and their
 
63
c           corresponding weights are given.
 
64
c
 
65
c           xgk    - abscissae of the 51-point kronrod rule
 
66
c                    xgk(2), xgk(4), ...  abscissae of the 25-point
 
67
c                    gauss rule
 
68
c                    xgk(1), xgk(3), ...  abscissae which are optimally
 
69
c                    added to the 25-point gauss rule
 
70
c
 
71
c           wgk    - weights of the 51-point kronrod rule
 
72
c
 
73
c           wg     - weights of the 25-point gauss rule
 
74
c
 
75
c
 
76
c gauss quadrature weights and kronron quadrature abscissae and weights
 
77
c as evaluated with 80 decimal digit arithmetic by l. w. fullerton,
 
78
c bell labs, nov. 1981.
 
79
c
 
80
      data wg  (  1) / 0.0113937985 0102628794 7902964113 235 d0 /
 
81
      data wg  (  2) / 0.0263549866 1503213726 1901815295 299 d0 /
 
82
      data wg  (  3) / 0.0409391567 0130631265 5623487711 646 d0 /
 
83
      data wg  (  4) / 0.0549046959 7583519192 5936891540 473 d0 /
 
84
      data wg  (  5) / 0.0680383338 1235691720 7187185656 708 d0 /
 
85
      data wg  (  6) / 0.0801407003 3500101801 3234959669 111 d0 /
 
86
      data wg  (  7) / 0.0910282619 8296364981 1497220702 892 d0 /
 
87
      data wg  (  8) / 0.1005359490 6705064420 2206890392 686 d0 /
 
88
      data wg  (  9) / 0.1085196244 7426365311 6093957050 117 d0 /
 
89
      data wg  ( 10) / 0.1148582591 4571164833 9325545869 556 d0 /
 
90
      data wg  ( 11) / 0.1194557635 3578477222 8178126512 901 d0 /
 
91
      data wg  ( 12) / 0.1222424429 9031004168 8959518945 852 d0 /
 
92
      data wg  ( 13) / 0.1231760537 2671545120 3902873079 050 d0 /
 
93
c
 
94
      data xgk (  1) / 0.9992621049 9260983419 3457486540 341 d0 /
 
95
      data xgk (  2) / 0.9955569697 9049809790 8784946893 902 d0 /
 
96
      data xgk (  3) / 0.9880357945 3407724763 7331014577 406 d0 /
 
97
      data xgk (  4) / 0.9766639214 5951751149 8315386479 594 d0 /
 
98
      data xgk (  5) / 0.9616149864 2584251241 8130033660 167 d0 /
 
99
      data xgk (  6) / 0.9429745712 2897433941 4011169658 471 d0 /
 
100
      data xgk (  7) / 0.9207471152 8170156174 6346084546 331 d0 /
 
101
      data xgk (  8) / 0.8949919978 7827536885 1042006782 805 d0 /
 
102
      data xgk (  9) / 0.8658470652 9327559544 8996969588 340 d0 /
 
103
      data xgk ( 10) / 0.8334426287 6083400142 1021108693 570 d0 /
 
104
      data xgk ( 11) / 0.7978737979 9850005941 0410904994 307 d0 /
 
105
      data xgk ( 12) / 0.7592592630 3735763057 7282865204 361 d0 /
 
106
      data xgk ( 13) / 0.7177664068 1308438818 6654079773 298 d0 /
 
107
      data xgk ( 14) / 0.6735663684 7346836448 5120633247 622 d0 /
 
108
      data xgk ( 15) / 0.6268100990 1031741278 8122681624 518 d0 /
 
109
      data xgk ( 16) / 0.5776629302 4122296772 3689841612 654 d0 /
 
110
      data xgk ( 17) / 0.5263252843 3471918259 9623778158 010 d0 /
 
111
      data xgk ( 18) / 0.4730027314 4571496052 2182115009 192 d0 /
 
112
      data xgk ( 19) / 0.4178853821 9303774885 1814394594 572 d0 /
 
113
      data xgk ( 20) / 0.3611723058 0938783773 5821730127 641 d0 /
 
114
      data xgk ( 21) / 0.3030895389 3110783016 7478909980 339 d0 /
 
115
      data xgk ( 22) / 0.2438668837 2098843204 5190362797 452 d0 /
 
116
      data xgk ( 23) / 0.1837189394 2104889201 5969888759 528 d0 /
 
117
      data xgk ( 24) / 0.1228646926 1071039638 7359818808 037 d0 /
 
118
      data xgk ( 25) / 0.0615444830 0568507888 6546392366 797 d0 /
 
119
      data xgk ( 26) / 0.0000000000 0000000000 0000000000 000 d0 /
 
120
c
 
121
      data wgk (  1) / 0.0019873838 9233031592 6507851882 843 d0 /
 
122
      data wgk (  2) / 0.0055619321 3535671375 8040236901 066 d0 /
 
123
      data wgk (  3) / 0.0094739733 8617415160 7207710523 655 d0 /
 
124
      data wgk (  4) / 0.0132362291 9557167481 3656405846 976 d0 /
 
125
      data wgk (  5) / 0.0168478177 0912829823 1516667536 336 d0 /
 
126
      data wgk (  6) / 0.0204353711 4588283545 6568292235 939 d0 /
 
127
      data wgk (  7) / 0.0240099456 0695321622 0092489164 881 d0 /
 
128
      data wgk (  8) / 0.0274753175 8785173780 2948455517 811 d0 /
 
129
      data wgk (  9) / 0.0307923001 6738748889 1109020215 229 d0 /
 
130
      data wgk ( 10) / 0.0340021302 7432933783 6748795229 551 d0 /
 
131
      data wgk ( 11) / 0.0371162714 8341554356 0330625367 620 d0 /
 
132
      data wgk ( 12) / 0.0400838255 0403238207 4839284467 076 d0 /
 
133
      data wgk ( 13) / 0.0428728450 2017004947 6895792439 495 d0 /
 
134
      data wgk ( 14) / 0.0455029130 4992178890 9870584752 660 d0 /
 
135
      data wgk ( 15) / 0.0479825371 3883671390 6392255756 915 d0 /
 
136
      data wgk ( 16) / 0.0502776790 8071567196 3325259433 440 d0 /
 
137
      data wgk ( 17) / 0.0523628858 0640747586 4366712137 873 d0 /
 
138
      data wgk ( 18) / 0.0542511298 8854549014 4543370459 876 d0 /
 
139
      data wgk ( 19) / 0.0559508112 2041231730 8240686382 747 d0 /
 
140
      data wgk ( 20) / 0.0574371163 6156783285 3582693939 506 d0 /
 
141
      data wgk ( 21) / 0.0586896800 2239420796 1974175856 788 d0 /
 
142
      data wgk ( 22) / 0.0597203403 2417405997 9099291932 562 d0 /
 
143
      data wgk ( 23) / 0.0605394553 7604586294 5360267517 565 d0 /
 
144
      data wgk ( 24) / 0.0611285097 1705304830 5859030416 293 d0 /
 
145
      data wgk ( 25) / 0.0614711898 7142531666 1544131965 264 d0 /
 
146
c       note: wgk (26) was calculated from the values of wgk(1..25)
 
147
      data wgk ( 26) / 0.0615808180 6783293507 8759824240 066 d0 /
 
148
c
 
149
c
 
150
c           list of major variables
 
151
c           -----------------------
 
152
c
 
153
c           centr  - mid point of the interval
 
154
c           hlgth  - half-length of the interval
 
155
c           absc   - abscissa
 
156
c           fval*  - function value
 
157
c           resg   - result of the 25-point gauss formula
 
158
c           resk   - result of the 51-point kronrod formula
 
159
c           reskh  - approximation to the mean value of f over (a,b),
 
160
c                    i.e. to i/(b-a)
 
161
c
 
162
c           machine dependent constants
 
163
c           ---------------------------
 
164
c
 
165
c           epmach is the largest relative spacing.
 
166
c           uflow is the smallest positive magnitude.
 
167
c
 
168
c***first executable statement  dqk51
 
169
      epmach = d1mach(4)
 
170
      uflow = d1mach(1)
 
171
c
 
172
      centr = 0.5d+00*(a+b)
 
173
      hlgth = 0.5d+00*(b-a)
 
174
      dhlgth = dabs(hlgth)
 
175
c
 
176
c           compute the 51-point kronrod approximation to
 
177
c           the integral, and estimate the absolute error.
 
178
c
 
179
      fc = f(centr)
 
180
      resg = wg(13)*fc
 
181
      resk = wgk(26)*fc
 
182
      resabs = dabs(resk)
 
183
      do 10 j=1,12
 
184
        jtw = j*2
 
185
        absc = hlgth*xgk(jtw)
 
186
        fval1 = f(centr-absc)
 
187
        fval2 = f(centr+absc)
 
188
        fv1(jtw) = fval1
 
189
        fv2(jtw) = fval2
 
190
        fsum = fval1+fval2
 
191
        resg = resg+wg(j)*fsum
 
192
        resk = resk+wgk(jtw)*fsum
 
193
        resabs = resabs+wgk(jtw)*(dabs(fval1)+dabs(fval2))
 
194
   10 continue
 
195
      do 15 j = 1,13
 
196
        jtwm1 = j*2-1
 
197
        absc = hlgth*xgk(jtwm1)
 
198
        fval1 = f(centr-absc)
 
199
        fval2 = f(centr+absc)
 
200
        fv1(jtwm1) = fval1
 
201
        fv2(jtwm1) = fval2
 
202
        fsum = fval1+fval2
 
203
        resk = resk+wgk(jtwm1)*fsum
 
204
        resabs = resabs+wgk(jtwm1)*(dabs(fval1)+dabs(fval2))
 
205
   15 continue
 
206
      reskh = resk*0.5d+00
 
207
      resasc = wgk(26)*dabs(fc-reskh)
 
208
      do 20 j=1,25
 
209
        resasc = resasc+wgk(j)*(dabs(fv1(j)-reskh)+dabs(fv2(j)-reskh))
 
210
   20 continue
 
211
      result = resk*hlgth
 
212
      resabs = resabs*dhlgth
 
213
      resasc = resasc*dhlgth
 
214
      abserr = dabs((resk-resg)*hlgth)
 
215
      if(resasc.ne.0.0d+00.and.abserr.ne.0.0d+00)
 
216
     *  abserr = resasc*dmin1(0.1d+01,(0.2d+03*abserr/resasc)**1.5d+00)
 
217
      if(resabs.gt.uflow/(0.5d+02*epmach)) abserr = dmax1
 
218
     *  ((epmach*0.5d+02)*resabs,abserr)
 
219
      return
 
220
      end