~maddevelopers/mg5amcnlo/2.9.4

« back to all changes in this revision

Viewing changes to vendor/CutTools/src/qcdloop/ffxdb0.f

pass to v2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
*###[ ffxdb0:
 
2
        subroutine ffxdb0(cdb0,cdb0p,xp,xma,xmb,ier)
 
3
***#[*comment:***********************************************************
 
4
*                                                                       *
 
5
*       Calculates the the derivative of the two-point function with    *
 
6
*       respect to p2 and the same times p2 (one is always well-defined)*
 
7
*                                                                       *
 
8
*       Input:  xp      (real)    k2, in B&D metric                     *
 
9
*               xma     (real)    mass2                                 *
 
10
*               xmb     (real)    mass2                                 *
 
11
*                                                                       *
 
12
*       Output: cdb0    (complex) dB0/dxp                               *
 
13
*               cdb0p   (complex) xp*dB0/dxp                            *
 
14
*               ier     (integer) # of digits lost, if >=100: error     *
 
15
*                                                                       *
 
16
*       Calls:  ffxdba                                                  *
 
17
*                                                                       *
 
18
***#]*comment:***********************************************************
 
19
*  #[ declarations:
 
20
        implicit none
 
21
*
 
22
*       arguments
 
23
*
 
24
        integer ier
 
25
        DOUBLE COMPLEX cdb0,cdb0p
 
26
        DOUBLE PRECISION xp,xma,xmb
 
27
*
 
28
*       local variables
 
29
*
 
30
        integer ier0
 
31
        DOUBLE PRECISION dmamb,dmap,dmbp
 
32
*
 
33
*       common blocks
 
34
*
 
35
        include 'ff.h'
 
36
*
 
37
*  #] declarations:
 
38
*  #[ check input:
 
39
        if ( lwrite ) then
 
40
            print *,'ffxdb0: input:'
 
41
            print *,'xma,xmb,xp,ier = ',xma,xmb,xp,ier
 
42
        endif
 
43
        if ( ltest ) then
 
44
            if ( xma .lt. 0 .or. xmb .lt. 0 ) then
 
45
                print *,'ffxdb0: error: xma,b < 0: ',xma,xmb
 
46
                stop
 
47
            endif
 
48
        endif
 
49
*  #] check input:
 
50
*  #[ get differences:
 
51
        ier0 = 0
 
52
        dmamb = xma - xmb
 
53
        dmap = xma - xp
 
54
        dmbp = xmb - xp
 
55
        if ( lwarn ) then
 
56
            if ( abs(dmamb) .lt. xloss*abs(xma) .and. xma .ne. xmb )
 
57
     +          call ffwarn(97,ier0,dmamb,xma)
 
58
            if ( abs(dmap) .lt. xloss*abs(xp) .and. xp .ne. xma )
 
59
     +          call ffwarn(98,ier0,dmap,xp)
 
60
            if ( abs(dmbp) .lt. xloss*abs(xp) .and. xp .ne. xmb )
 
61
     +          call ffwarn(99,ier0,dmbp,xp)
 
62
        endif
 
63
*  #] get differences:
 
64
*  #[ calculations:
 
65
        call ffxdbp(cdb0,cdb0p,xp,xma,xmb,dmap,dmbp,dmamb,ier)
 
66
        if ( lwrite ) print *,'B0'' = ',cdb0,cdb0p,ier
 
67
*  #] calculations:
 
68
*###] ffxdb0:
 
69
        end
 
70
*###[ ffxdbp:
 
71
        subroutine ffxdbp(cdb0,cdb0p,xp,xma,xmb,dmap,dmbp,dmamb,ier)
 
72
***#[*comment:***********************************************************
 
73
*                                                                       *
 
74
*       calculates the derivatives of the two-point function            *
 
75
*       Veltman) for all possible cases: masses equal, unequal,         *
 
76
*       equal to zero.                                                  *
 
77
*                                                                       *
 
78
*       Input:  xp      (real) p.p, in B&D metric                       *
 
79
*               xma     (real) mass2,                                   *
 
80
*               xmb     (real) mass2,                                   *
 
81
*               dm[ab]p (real) xm[ab] - xp                              *
 
82
*               dmamb   (real) xma - xmb                                *
 
83
*                                                                       *
 
84
*       Output: cdb0    (complex) B0' = dB0/dxp                         *
 
85
*               cdb0p   (complex) xp*dB0/dxp                            *
 
86
*               ier     (integer) 0=ok,>0=numerical problems,>100=error *
 
87
*                                                                       *
 
88
*       Calls:  ffxdbp.                                                 *
 
89
*                                                                       *
 
90
***#]*comment:***********************************************************
 
91
*  #[ declarations:
 
92
        implicit none
 
93
*
 
94
*       arguments
 
95
*
 
96
        integer ier
 
97
        DOUBLE COMPLEX cdb0,cdb0p
 
98
        DOUBLE PRECISION xp,xma,xmb,dmap,dmbp,dmamb
 
99
*
 
100
*       local variables
 
101
*
 
102
        integer i,initeq,jsign,initir
 
103
        DOUBLE PRECISION ax,ffbnd,
 
104
     +          xprceq,bdeq01,bdeq05,bdeq11,bdeq17,bdeq25,
 
105
     +          xprcn3,bdn301,bdn305,bdn310,bdn315,
 
106
     +          xprcn5,bdn501,bdn505,bdn510,bdn515,
 
107
     +          xprec0,bdn001,bdn005,bdn010,bdn015,bdn020
 
108
        DOUBLE PRECISION xcheck,xm,dmp,xm1,xm2,dm1m2,dm1p,
 
109
     +          dm2p,s,s1,s1a,s1b,s1p,s2,s2a,s2b,s2p,x,y,som,
 
110
     +          xlam,slam,xlogmm,alpha,alph1,xnoe,xpneq(30),
 
111
     +          xx,dfflo1,dfflo3,d1,d2,diff,h,a,b,c,d,beta,
 
112
     +          betm2n,xmax,s1c,s1d,s1e,s1f,s3
 
113
        DOUBLE COMPLEX cc,zxfflg
 
114
        save initeq,xpneq,initir,
 
115
     +          xprceq,bdeq01,bdeq05,bdeq11,bdeq17,bdeq25,
 
116
     +          xprcn3,bdn301,bdn305,bdn310,bdn315,
 
117
     +          xprcn5,bdn501,bdn505,bdn510,bdn515,
 
118
     +          xprec0,bdn001,bdn005,bdn010,bdn015,bdn020
 
119
*
 
120
*       common blocks
 
121
*
 
122
        include 'ff.h'
 
123
        DOUBLE PRECISION delta
 
124
        common /ffcut/ delta
 
125
*
 
126
*       data
 
127
*
 
128
        data xprceq /-1./
 
129
        data xprec0 /-1./
 
130
        data xprcn3 /-1./
 
131
        data xprcn5 /-1./
 
132
        data initeq /0/
 
133
*
 
134
*  #] declarations:
 
135
*  #[ check input:
 
136
        if (ltest) then
 
137
            xcheck = xma - xmb - dmamb
 
138
            if ( abs(xcheck) .gt. precx*max(abs(xma),abs(xmb),abs(
 
139
     +                  dmamb))/xloss ) then
 
140
                print *,'ffxdbp: input not OK, dmamb <> xma-xmb',xcheck
 
141
            endif
 
142
            xcheck = -xp + xma - dmap
 
143
            if ( abs(xcheck) .gt. precx*max(abs(xp),abs(xma),abs(
 
144
     +                  dmap))/xloss ) then
 
145
                print *,'ffxdbp: input not OK, dmap <> xma - xp',xcheck
 
146
            endif
 
147
            xcheck = -xp + xmb - dmbp
 
148
            if ( abs(xcheck) .gt. precx*max(abs(xp),abs(xmb),abs(
 
149
     +                  dmbp))/xloss ) then
 
150
                print *,'ffxdbp: input not OK, dmbp <> xmb - xp',xcheck
 
151
            endif
 
152
        endif
 
153
*  #] check input:
 
154
*  #[ which case:
 
155
*
 
156
*       sort according to the type of masscombination encountered:
 
157
*       100: both masses zero, 200: one equal to zero, 300: both equal
 
158
*       400: rest.
 
159
*
 
160
        if ( xma .eq. 0 ) then
 
161
                if ( xmb .eq. 0 ) then
 
162
                        goto 100
 
163
                endif
 
164
                xm = xmb
 
165
                dmp = dmbp
 
166
                goto 200
 
167
        endif
 
168
        if ( xmb .eq. 0 ) then
 
169
                xm = xma
 
170
                dmp = dmap
 
171
                goto 200
 
172
        elseif ( dmamb .eq. 0 ) then
 
173
                xm = xma
 
174
                dmp = dmap
 
175
                goto 300
 
176
        elseif ( xma .gt. xmb ) then
 
177
                xm2 = xma
 
178
                xm1 = xmb
 
179
                dm1m2 = -dmamb
 
180
                dm1p = dmbp
 
181
                dm2p = dmap
 
182
        else
 
183
                xm1 = xma
 
184
                xm2 = xmb
 
185
                dm1m2 = dmamb
 
186
                dm1p = dmap
 
187
                dm2p = dmbp
 
188
        endif
 
189
        goto 400
 
190
*  #] which case:
 
191
*  #[ both masses equal to zero:
 
192
  100   continue
 
193
        if ( xp.ne.0 ) cdb0 = -1/xp
 
194
        cdb0p = -1
 
195
        return
 
196
*  #] both masses equal to zero:
 
197
*  #[ one mass equal to zero:
 
198
  200   continue
 
199
*
 
200
*       special case xp = 0
 
201
*
 
202
        if ( xp .eq. 0 ) then
 
203
            cdb0p = 0
 
204
            cdb0 = 1/(2*xm)
 
205
            goto 990
 
206
*
 
207
*       special case xp = xm
 
208
*
 
209
        elseif ( dmp.eq.0 ) then
 
210
            if ( lsmug ) then
 
211
                if ( DBLE(cmipj(1,3)).lt.DBLE(cmipj(2,3)) ) then
 
212
                    cdb0p = -1 - log(cmipj(1,3)*DBLE(1/xm))
 
213
                else
 
214
                    cdb0p = -1 - log(cmipj(2,3)*DBLE(1/xm))
 
215
                endif
 
216
            else
 
217
                if ( initir.eq.0 ) then
 
218
                    initir = 1
 
219
                    print *,'ffxdb0: IR divergent B0'', using cutoff ',
 
220
     +                  delta 
 
221
                endif
 
222
                if ( delta.eq.0 ) then
 
223
                    call fferr(74,ier)
 
224
                    cdb0p = 0
 
225
                else
 
226
                    cdb0p = -1 + log(xm/delta)/2
 
227
                endif
 
228
            endif
 
229
            cdb0 = cdb0p*(1/DBLE(xp))
 
230
            goto 990
 
231
        endif
 
232
*
 
233
*       Normal case:
 
234
*
 
235
        x = xp/xm
 
236
        ax = abs(x)
 
237
        if ( ax .lt. xloss ) then
 
238
*       #[ Taylor expansion:
 
239
            if ( xprec0 .ne. precx ) then
 
240
                xprec0 = precx
 
241
                bdn001 = ffbnd(2,1,xninv)
 
242
                bdn005 = ffbnd(2,5,xninv)
 
243
                bdn010 = ffbnd(2,10,xninv)
 
244
                bdn015 = ffbnd(2,15,xninv)
 
245
                bdn020 = ffbnd(2,20,xninv)
 
246
            endif
 
247
            if ( lwarn .and. ax .gt. bdn020 ) then
 
248
                call ffwarn(15,ier,precx,xninv(21)*ax**20)
 
249
            endif
 
250
            if ( ax .gt. bdn015 ) then
 
251
                som = x*(xninv(17) + x*(xninv(18) + x*(xninv(19) +
 
252
     +                x*(xninv(20) + x*(xninv(21) )))))
 
253
            else
 
254
                som = 0
 
255
            endif
 
256
            if ( ax .gt. bdn010 ) then
 
257
                som = x*(xninv(12) + x*(xninv(13) + x*(xninv(14) +
 
258
     +                x*(xninv(15) + x*(xninv(16) + som )))))
 
259
            endif
 
260
            if ( ax .gt. bdn005 ) then
 
261
                som = x*(xninv(7) + x*(xninv(8) + x*(xninv(9) +
 
262
     +                x*(xninv(10) + x*(xninv(11) + som )))))
 
263
            endif
 
264
            if ( ax .gt. bdn001 ) then
 
265
                som = x*(xninv(3) + x*(xninv(4) + x*(xninv(5) +
 
266
     +                x*(xninv(6) + som ))))
 
267
            endif
 
268
            cdb0p = x*(xninv(2) + som)
 
269
            if ( lwrite ) then
 
270
                print *,'cdb0p = ',cdb0p
 
271
                print *,'verg   ',-1 - xm/xp*dfflo1(x,ier),1
 
272
            endif
 
273
*       #] Taylor expansion:
 
274
        else
 
275
*       #[ short formula:
 
276
            s = log(abs(dmp/xm))
 
277
            cdb0p = -(1 + s*xm/xp)
 
278
            if ( xp.gt.xm ) cdb0p = cdb0p+DCMPLX(DBLE(0),DBLE(xm/xp*pi))
 
279
*       #] short formula:
 
280
        endif
 
281
        cdb0 = cdb0p*(1/DBLE(xp))
 
282
        goto 990
 
283
*  #] one mass equal to zero:
 
284
*  #[ both masses equal:
 
285
  300   continue
 
286
*
 
287
*       Both masses are equal.  Not only this speeds up things, some
 
288
*       cancellations have to be avoided as well.
 
289
*
 
290
*       first a special case
 
291
*
 
292
        if ( abs(xp) .lt. 8*xloss*xm ) then
 
293
* -#[       taylor expansion:
 
294
*
 
295
*           a Taylor expansion seems appropriate as the result will go
 
296
*           as k^2 but seems to go as 1/k !!
 
297
*
 
298
*--#[       data and bounds:
 
299
            if ( initeq .eq. 0 ) then
 
300
                initeq = 1
 
301
                xpneq(1) = x1/6
 
302
                do 1 i=2,30
 
303
                    xpneq(i) = - xpneq(i-1)*DBLE(i)/DBLE(2*(2*i+1))
 
304
    1           continue
 
305
            endif
 
306
            if (xprceq .ne. precx ) then
 
307
*
 
308
*               calculate the boundaries for the number of terms to be
 
309
*               included in the taylorexpansion
 
310
*
 
311
                xprceq = precx
 
312
                bdeq01 = ffbnd(1,1,xpneq)
 
313
                bdeq05 = ffbnd(1,5,xpneq)
 
314
                bdeq11 = ffbnd(1,11,xpneq)
 
315
                bdeq17 = ffbnd(1,17,xpneq)
 
316
                bdeq25 = ffbnd(1,25,xpneq)
 
317
            endif
 
318
*--#]       data and bounds:
 
319
            x = -xp/xm
 
320
            ax = abs(x)
 
321
            if ( lwarn .and. ax .gt. bdeq25 ) then
 
322
                call ffwarn(15,ier,precx,abs(xpneq(25))*ax**25)
 
323
            endif
 
324
            if ( ax .gt. bdeq17 ) then
 
325
                som = x*(xpneq(18) + x*(xpneq(19) + x*(xpneq(20) +
 
326
     +          x*(xpneq(21) + x*(xpneq(22) + x*(xpneq(23) +
 
327
     +          x*(xpneq(24) + x*(xpneq(25) ))))))))
 
328
            else
 
329
                som = 0
 
330
            endif
 
331
            if ( ax .gt. bdeq11 ) then
 
332
                som = x*(xpneq(12) + x*(xpneq(13) + x*(xpneq(14) +
 
333
     +          x*(xpneq(15) + x*(xpneq(16) + x*(xpneq(17) + som ))))
 
334
     +          ))
 
335
            endif
 
336
            if ( ax .gt. bdeq05 ) then
 
337
                som = x*(xpneq(6) + x*(xpneq(7) + x*(xpneq(8) + x*(
 
338
     +          xpneq(9) + x*(xpneq(10) + x*(xpneq(11) + som ))))))
 
339
            endif
 
340
            if ( ax .gt. bdeq01 ) then
 
341
                som = x*(xpneq(2) + x*(xpneq(3) + x*(xpneq(4) + x*(
 
342
     +          xpneq(5) + som ))))
 
343
            endif
 
344
            cdb0p = -x*(xpneq(1)+som)
 
345
            if (lwrite) then
 
346
                print *,'ffxdbp: m1 = m2, Taylor expansion in ',x
 
347
                print *,'cdb0p = ',cdb0p
 
348
            endif
 
349
            if ( xp.ne.0 ) then
 
350
                cdb0 = cdb0p*(1/DBLE(xp))
 
351
            else
 
352
                cdb0 = xpneq(1)/xm
 
353
            endif
 
354
            goto 990
 
355
* -#]       taylor expansion:
 
356
        endif
 
357
* -#[   normal case:
 
358
*
 
359
*       normal case
 
360
*
 
361
        call ffxlmb(xlam,-xp,-xm,-xm,dmp,dmp,x0,ier)
 
362
        if ( xlam .eq. 0 ) then
 
363
            call fferr(86,ier)
 
364
            return
 
365
        elseif ( xlam .gt. 0 ) then
 
366
*           cases 1,2 and 4
 
367
            slam = sqrt(xlam)
 
368
            s2a = dmp + xm
 
369
            s2 = s2a + slam
 
370
            if ( abs(s2) .gt. xloss*slam ) then
 
371
*               looks fine
 
372
                jsign = 1
 
373
            else
 
374
                s2 = s2a - slam
 
375
                jsign = -1
 
376
            endif
 
377
            ax = abs(s2/(2*xm))
 
378
            if ( ax .lt. xalogm ) then
 
379
                if ( lwarn ) call ffwarn(16,ier,ax,xalogm)
 
380
                s = 0
 
381
            elseif( ax-1 .lt. .1 .and. s2 .gt. 0 ) then
 
382
*               In this case a quicker and more accurate way is to
 
383
*               calculate log(1-x).
 
384
                s2 = (xp - slam)
 
385
*               the following line is superfluous.
 
386
                if ( lwarn .and. abs(s2) .lt. xloss*slam )
 
387
     +                  call ffwarn(17,ier,s2,slam)
 
388
                s = 2*xm/slam*dfflo1(s2/(2*xm),ier)
 
389
            else
 
390
*               finally the normal case
 
391
                s = 2*xm/slam*log(ax)
 
392
                if ( jsign .eq. -1 ) s = -s
 
393
            endif
 
394
            if ( xp .gt. 2*xm ) then
 
395
*               in this case ( xlam>0, so xp>(2*m)^2) ) there also
 
396
*               is an imaginary part
 
397
                y = pi*2*xm/slam
 
398
            else
 
399
                y = 0
 
400
            endif
 
401
        else
 
402
*           the root is complex (k^2 between 0 and (2*m1)^2)
 
403
            slam = sqrt(-xlam)
 
404
            s = 4*xm/slam*atan2(xp,slam)
 
405
            y = 0
 
406
        endif
 
407
        if (lwrite) print *,'s =   ',s
 
408
        xx = s - 1
 
409
        if ( lwarn .and. abs(xx).lt.xloss ) call ffwarn(18,ier,xx,x1)
 
410
        cdb0p = DCMPLX(DBLE(xx),DBLE(y))
 
411
        cdb0 = cdb0p*(1/DBLE(xp))
 
412
        goto 990
 
413
* -#]   normal case:
 
414
*
 
415
*  #] both masses equal:
 
416
*  #[ unequal nonzero masses:
 
417
* -#[   get log(xm2/xm1):
 
418
  400   continue
 
419
        x = xm2/xm1
 
420
        if ( 1 .lt. xalogm*x ) then
 
421
            call fferr(8,ier)
 
422
            xlogmm = 0
 
423
        elseif ( abs(x-1) .lt. xloss ) then
 
424
            xlogmm = dfflo1(dm1m2/xm1,ier)
 
425
        else
 
426
            xlogmm = log(x)
 
427
        endif
 
428
* -#]   get log(xm2/xm1):
 
429
* -#[   xp = 0:
 
430
*
 
431
*       first a special case
 
432
*
 
433
        if ( xp .eq. 0 ) then
 
434
*
 
435
*           repaired 19-nov-1993, see b2.frm
 
436
*
 
437
            s1 = xm1*xm2*xlogmm/dm1m2**3
 
438
            s2 = (xm1+xm2)/(2*dm1m2**2)
 
439
            s = s1 + s2
 
440
            if ( abs(s) .lt. xloss**2*s2 ) then
 
441
*
 
442
*               second try
 
443
*
 
444
                h = dfflo3(dm1m2/xm1,ier)
 
445
                s1 = -xm1*h/dm1m2**2
 
446
                s2 = 1/(2*xm1)
 
447
                s3 = xm1**2*h/dm1m2**3
 
448
                s = s1 + s2 + s3
 
449
                if ( abs(s) .lt. xloss*max(abs(s2),abs(s3)) ) then
 
450
                    call ffwarn(228,ier,s,s2)
 
451
                endif
 
452
            endif
 
453
            cdb0 = s
 
454
            cdb0p = 0
 
455
            goto 990
 
456
        endif
 
457
* -#]   xp = 0:
 
458
* -#[   normal case:
 
459
*
 
460
*       proceeding with the normal case
 
461
*
 
462
        call ffxlmb(xlam,-xp,-xm2,-xm1,dm2p,dm1p,dm1m2,ier)
 
463
        diff = xlam + xp*(dm2p+xm1)
 
464
        if ( lwrite ) print *,'diff = ',diff
 
465
        if ( abs(diff) .lt. xloss*xlam ) then
 
466
            h = dm1m2**2 - xp*(xm1+xm2)
 
467
            if ( lwrite ) print *,'diff+= ',h
 
468
            if ( abs(h) .lt. xloss*dm1m2**2 ) then
 
469
                if ( dm1m2**2 .lt. abs(xlam) ) diff = h
 
470
                if ( lwarn ) then
 
471
                    call ffwarn(221,ier,diff,min(dm1m2**2,abs(xlam)))
 
472
                endif
 
473
            endif
 
474
        endif
 
475
        if ( xlam .eq. 0 ) then
 
476
            call fferr(86,ier)
 
477
            return
 
478
        elseif ( xlam .gt. 0 ) then
 
479
*           cases k^2 < -(m2+m1)^2 or k^2 > -(m2-m1)^2:
 
480
*--#[       first try:
 
481
*           first try the normal way
 
482
            slam = sqrt(xlam)
 
483
            s2a = dm2p + xm1
 
484
            s2 = s2a + slam
 
485
            if ( abs(s2) .gt. xloss*slam ) then
 
486
*               looks fine
 
487
                jsign = 1
 
488
            else
 
489
                s2 = s2a - slam
 
490
                jsign = -1
 
491
            endif
 
492
            s2 = s2**2/(4*xm1*xm2)
 
493
            if ( abs(s2) .lt. xalogm ) then
 
494
                call fferr(9,ier)
 
495
                s2 = 0
 
496
            elseif ( abs(s2-1) .lt. xloss ) then
 
497
                if ( jsign.eq.1 ) then
 
498
                    if (lwrite) print *,'s2 ',-diff/(2*slam*xp)*log(s2)
 
499
                    s2 = -slam*(s2a+slam)/(2*xm1*xm2)
 
500
                    s2 = -diff/(2*slam*xp)*dfflo1(s2,ier)
 
501
                else
 
502
                    ier = ier + 50
 
503
                    print *,'ffxdb0: untested: s2 better in first try'
 
504
                    if (lwrite) print *,'s2 ',+diff/(2*slam*xp)*log(s2)
 
505
                    s2 = +slam*(s2a-slam)/(2*xm1*xm2)
 
506
                    s2 = +diff/(2*slam*xp)*dfflo1(s2,ier)
 
507
                endif
 
508
                if ( lwrite ) print *,'s2+ ',s2,jsign
 
509
            else
 
510
                s2 = -diff/(2*slam*xp)*log(s2)
 
511
                if ( jsign .eq. -1 ) s2 = -s2
 
512
            endif
 
513
            s1 = -dm1m2*xlogmm/(2*xp)
 
514
            xx = s1+s2-1
 
515
            if (lwrite) then
 
516
                print *,'ffxdbp: lam>0, first try, xx  = ',xx,s1,s2,-1
 
517
            endif
 
518
*--#]       first try:
 
519
            if ( abs(xx) .lt. xloss**2*max(abs(s1),abs(s2)) ) then
 
520
*--#[           second try:
 
521
*               this is unacceptable, try a better solution
 
522
                s1a = diff + slam*dm1m2
 
523
                if (lwrite) print *,'s1 = ',-s1a/(2*xp*slam),diff/
 
524
     +                  (2*xp*slam)
 
525
                if ( abs(s1a) .gt. xloss*diff ) then
 
526
*                   this works
 
527
                    s1 = -s1a/(2*xp*slam)
 
528
                else
 
529
*                   by division a more accurate form can be found
 
530
                    s1 = -2*xm1*xm2*xp/(slam*(diff - slam*dm1m2))
 
531
                    if (lwrite) print *,'s1+= ',s1
 
532
                endif
 
533
                s = s1
 
534
                s1 = s1*xlogmm
 
535
                if ( abs(xp) .lt. xm2 ) then
 
536
                    s2a = xp - dm1m2
 
537
                else
 
538
                    s2a = xm2 - dm1p
 
539
                endif
 
540
                s2 = s2a - slam
 
541
                if (lwrite) print *,'s2 = ',s2/(2*xm2),slam/(2*xm2)
 
542
                if ( abs(s2) .gt. xloss*slam ) then
 
543
*                   at least reasonable
 
544
                    s2 = s2 / (2*xm2)
 
545
                else
 
546
*                   division again
 
547
                    s2 = (2*xp) / (s2a+slam)
 
548
                    if (lwrite) print *,'s2+= ',s2
 
549
                endif
 
550
                if ( abs(s2) .lt. .1 ) then
 
551
*                   choose a quick way to get the logarithm
 
552
                    s2 = dfflo1(s2,ier)
 
553
                elseif ( s2.eq.1 ) then
 
554
                    print *,'ffxdbp: error: arg log would be 0!'
 
555
                    print *,'        xp,xma,xmb = ',xp,xma,xmb
 
556
                    goto 600
 
557
                else
 
558
                    h = abs(1-s2)
 
559
                    s2 = zxfflg(h,0,c0,ier)
 
560
                endif
 
561
                s2 = -diff/(slam*xp)*s2
 
562
                xx = s1 + s2 - 1
 
563
                if (lwrite) then
 
564
                    print *,'ffxdbp: lam>0, 2nd try, xx  = ',xx,s1,s2,-1
 
565
                endif
 
566
*--#]           second try:
 
567
                if ( abs(xx) .lt. xloss**2*max(abs(s1),abs(s2)) ) then
 
568
*--#[               third try:
 
569
*                   (we accept two times xloss because that's the same
 
570
*                   as in this try)
 
571
*                   A Taylor expansion might work.  We expand
 
572
*                   inside the logs. Only do the necessary work.
 
573
*
 
574
*               #[ split up 1:
 
575
                    xnoe = s2a+slam
 
576
                    a = 1
 
577
                    b = 2/xnoe-1/xp
 
578
                    c = -4/(xp*xnoe)
 
579
                    d = sqrt((2/xnoe)**2 + 1/xp**2)
 
580
                    call ffroot(d1,d2,a,b,c,d,ier)
 
581
                    if ( xp.gt.0 ) then
 
582
                        beta = d2
 
583
                    else
 
584
                        beta = d1
 
585
                    endif
 
586
                    alpha = beta*diff/slam
 
587
                    alph1 = 1-alpha
 
588
                    if ( alph1 .lt. xloss ) then
 
589
                        s1a = 4*xp**2*xm1*xm2/(slam*dm1m2*(diff-slam*
 
590
     +                          dm1m2))
 
591
                        s1b = -diff/slam*4*xm1*xp/(dm1m2*xnoe*(2*xp-
 
592
     +                          xnoe))
 
593
                        b = -1/xp
 
594
                        c = -(2/xnoe)**2
 
595
                        call ffroot(d1,d2,a,b,c,d,ier)
 
596
                        if ( xp.gt.0 ) then
 
597
                            betm2n = d2
 
598
                        else
 
599
                            betm2n = d1
 
600
                        endif
 
601
                        d1 = s1a + s1b - diff/slam*betm2n
 
602
                        if ( lwrite ) then
 
603
                            print *,'alph1    = ',d1,s1a,s1b,-diff/slam*
 
604
     +                          betm2n
 
605
                            print *,'verg       ',1-alpha
 
606
                        endif
 
607
                        xmax = max(abs(s1a),abs(s1b))
 
608
                        if ( xmax .lt. 1 ) then
 
609
                            alph1 = d1
 
610
                        else
 
611
                            xmax = 1
 
612
                        endif
 
613
                        if ( lwarn .and. abs(alph1).lt.xloss*xmax ) then
 
614
                            call ffwarn(222,ier,alph1,xmax)
 
615
                            if ( lwrite ) print *,'d1,s1a,s2b,... = ',
 
616
     +                          d1,s1a,s1b,diff/slam*betm2n
 
617
                        endif
 
618
                    else
 
619
                        betm2n = beta - 2/xnoe
 
620
                    endif
 
621
                    if ( lwrite ) then
 
622
                        print *,'     s1 - alph1 = ',s1-alph1
 
623
                        print *,'     s2 - alpha = ',s2-alpha
 
624
                    endif
 
625
*               #] split up 1:
 
626
*               #[ s2:
 
627
*
 
628
*                   first s2:
 
629
*
 
630
  490               continue
 
631
                    s2p = s2 - alpha
 
632
                    if ( abs(s2p) .lt. xloss*abs(s2) ) then
 
633
* -#[                   bounds:
 
634
*                       determine the boundaries for 1,5,10,15 terms
 
635
                        if ( xprcn5 .ne. precx ) then
 
636
                            xprcn5 = precx
 
637
                            bdn501 = ffbnd(3,1,xinfac)
 
638
                            bdn505 = ffbnd(3,5,xinfac)
 
639
                            bdn510 = ffbnd(3,10,xinfac)
 
640
                            bdn515 = ffbnd(3,15,xinfac)
 
641
                        endif
 
642
* -#]                   bounds:
 
643
                        x = beta*xp
 
644
                        ax = abs(x)
 
645
                        if ( lwarn .and. ax .gt. bdn515 ) then
 
646
*                           do not do the Taylor expansion
 
647
                            call ffwarn(23,ier,s2p,s2)
 
648
                            goto 495
 
649
                        endif
 
650
                        if ( ax .gt. bdn510 ) then
 
651
                            s2a = x*(xinfac(13) + x*(xinfac(14) + x*(
 
652
     +                               xinfac(15) + x*(xinfac(16) + x*(
 
653
     +                               xinfac(17))))))
 
654
                        else
 
655
                            s2a = 0
 
656
                        endif
 
657
                        if ( ax .gt. bdn505 ) then
 
658
                            s2a = x*(xinfac(8) + x*(xinfac(9) + x*(
 
659
     +                              xinfac(10) + x*(xinfac(11) + x*(
 
660
     +                              xinfac(12) + s2a)))))
 
661
                        endif
 
662
                        if ( ax .gt. bdn501 ) then
 
663
                            s2a = x*(xinfac(4) + x*(xinfac(5) + x*(
 
664
     +                               xinfac(6) + x*(xinfac(7) + s2a))))
 
665
                        endif
 
666
                        s2a = x**3*(xinfac(3)+s2a)
 
667
                        s2b = 2*xp/xnoe*(s2a + x**2/2)
 
668
                        s2p = s2b - s2a
 
669
                        if ( lwarn .and. abs(s2p).lt.xloss*abs(s2a) )
 
670
     +                          call ffwarn(24,ier,s2p,s2a)
 
671
                        s2p = -diff/(xp*slam)*dfflo1(s2p,ier)
 
672
                        if (lwrite) then
 
673
                            print *,'ffxdbp: Taylor expansion of s2-a'
 
674
                            print *,'        in x = ',x
 
675
                            print *,'        gives s2p = ',s2p
 
676
                        endif
 
677
                    endif
 
678
*               #] s2:
 
679
*               #[ s1:
 
680
*
 
681
*                   next s1:
 
682
*
 
683
  495               continue
 
684
                    s1p = s1 - alph1
 
685
                    if ( abs(s1p) .lt. xloss*abs(s1) ) then
 
686
* -#[                   bounds:
 
687
*                       determine the boundaries for 1,5,10,15 terms
 
688
                        if ( xprcn3 .ne. precx ) then
 
689
                            xprcn3 = precx
 
690
                            bdn301 = ffbnd(3,1,xinfac)
 
691
                            bdn305 = ffbnd(3,5,xinfac)
 
692
                            bdn310 = ffbnd(3,10,xinfac)
 
693
                            bdn315 = ffbnd(3,15,xinfac)
 
694
                        endif
 
695
* -#]                   bounds:
 
696
*
 
697
                        x = slam*(diff-slam*dm1m2)*alph1/(2*xp*xm1*xm2)
 
698
                        h = (2*xp*(xm1+xm2) - xp**2)/(slam-dm1m2)
 
699
                        ax = abs(x)
 
700
                        if ( lwarn .and. ax .gt. bdn315 ) then
 
701
*                           do not do the Taylor expansion
 
702
                            call ffwarn(21,ier,s1p,s1)
 
703
                            goto 500
 
704
                        endif
 
705
*
 
706
*                       see form job gets1.frm
 
707
*
 
708
                        s1b = diff*(diff-slam*dm1m2)*betm2n/(2*xp*xm1*
 
709
     +                          xm2)
 
710
                        s1c = 1/(xm1*xnoe*(2*xp-xnoe))*(
 
711
     +                          xp*( 4*xp*xm2 + 2*dm1m2**2/xm2*(xp-h) +
 
712
     +                          2*dm1m2*(3*xp-h) - 8*dm1m2**2 )
 
713
     +                          - 2*dm1m2**3/xm2*(3*xp-h)
 
714
     +                          + 4*dm1m2**4/xm2
 
715
     +                          )
 
716
                        if ( lwrite ) then
 
717
                            print *,'s1c was ',-2*xp/dm1m2 + 2*diff*
 
718
     +                          (diff-slam*dm1m2)/(xm2*dm1m2*xnoe*(2*xp-
 
719
     +                          xnoe)) + dm1m2/xm1
 
720
                            print *,'  en is ',s1c
 
721
                            print *,'s1b+s1c was ',dm1m2/xm1-x
 
722
                            print *,'      en is ',s1b+s1c
 
723
                        endif
 
724
                        s1d = x*dm1m2/xm1
 
725
                        s1e = -x**2/2
 
726
                        if ( ax .gt. bdn310 ) then
 
727
                            s1a = x*(xinfac(13) + x*(xinfac(14) + x*(
 
728
     +                               xinfac(15) + x*(xinfac(16) + x*(
 
729
     +                               xinfac(17))))))
 
730
                        else
 
731
                            s1a = 0
 
732
                        endif
 
733
                        if ( ax .gt. bdn305 ) then
 
734
                            s1a = x*(xinfac(8) + x*(xinfac(9) + x*(
 
735
     +                             xinfac(10) + x*(xinfac(11) + x*(
 
736
     +                             xinfac(12) + s1a)))))
 
737
                        endif
 
738
                        if ( ax .gt. bdn301 ) then
 
739
                            s1a = x*(xinfac(4) + x*(xinfac(5) + x*(
 
740
     +                               xinfac(6) + x*(xinfac(7) + s1a))))
 
741
                        endif
 
742
                        s1a = -x**3 *(xinfac(3) + s1a)
 
743
                        s1f = dm1m2/xm1*(x**2/2 - s1a)
 
744
                        s1p = s1e + s1d + s1c + s1b + s1a + s1f
 
745
                        xmax = max(abs(s1a),abs(s1b),abs(s1c),abs(s1d),
 
746
     +                          abs(s1e))
 
747
                        if ( lwarn .and. abs(s1p).lt.xloss*xmax ) then
 
748
                            call ffwarn(223,ier,s1p,xmax)
 
749
                            if ( lwrite )
 
750
     +                          print *,'s1p,s1e,s1d,s1c,s1b,s1a,s1f = '
 
751
     +                          ,s1p,s1e,s1d,s1c,s1b,s1a,s1f
 
752
                        endif
 
753
                        s1p = s*dfflo1(s1p,ier)
 
754
                        if (lwrite) then
 
755
                            print *,'s1a = ',s1a
 
756
                            print *,'s1b = ',s1b
 
757
                            print *,'s1c = ',s1c
 
758
                            print *,'s1d = ',s1d
 
759
                            print *,'s1e = ',s1e
 
760
                            print *,'s1f = ',s1f
 
761
                            print *,'s   = ',s
 
762
                            print *,'ffxdbp: Taylor exp. of s1-(1-a)'
 
763
                            print *,'        in x = ',x
 
764
                            print *,'        gives s1p = ',s1p
 
765
                            print *,'        verg        ',s*log(xm2/xm1
 
766
     +                          *exp(x))
 
767
                        endif
 
768
                    endif
 
769
*               #] s1:
 
770
*
 
771
*                   finally ...
 
772
*
 
773
  500               continue
 
774
                    xx = s1p + s2p
 
775
                    if ( lwarn .and. abs(xx) .lt. xloss*abs(s1p) ) then
 
776
                        call ffwarn(25,ier,xx,s1p)
 
777
                    endif
 
778
*--#]               third try:
 
779
                endif
 
780
            endif
 
781
  600       continue
 
782
            if ( xp .gt. xm1+xm2 ) then
 
783
*--#[           imaginary part:
 
784
*               in this case ( xlam>0, so xp>(m1+m2)^2) ) there also
 
785
*               is an imaginary part
 
786
                y = -pi*diff/(slam*xp)
 
787
            else
 
788
                y = 0
 
789
*--#]           imaginary part:
 
790
            endif
 
791
         else
 
792
*           the root is complex (k^2 between -(m1+m2)^2 and -(m2-m1)^2)
 
793
*--#[       first try:
 
794
            slam = sqrt(-xlam)
 
795
            xnoe = dm2p + xm1
 
796
            s1 = -(dm1m2/(2*xp))*xlogmm
 
797
            s2 = -diff/(slam*xp)*atan2(slam,xnoe)
 
798
            xx = s1 + s2 - 1
 
799
            if (lwrite) then
 
800
                print *,'ffxdbp: lam<0, first try, xx  = ',xx,s1,s2,-1
 
801
*               alpha = -xlam/(2*xp*xnoe)
 
802
*               alph1 = -(xp**2-dm1m2**2)/(2*xp*xnoe)
 
803
*               print *,'        alpha = ',alpha
 
804
*               print *,'        s1 = ',s1,' - 2alph1 = ',s1-2*alph1
 
805
*               print *,'        s2 = ',s2,' - 2alpha = ',s2-2*alpha
 
806
            endif
 
807
*--#]       first try:
 
808
            if ( lwarn .and. abs(xx).lt.xloss**2*max(abs(s1),abs(s2)) )
 
809
     +                  then
 
810
                call ffwarn(224,ier,xx,max(abs(s1),abs(s2)))
 
811
            endif
 
812
            y = 0
 
813
        endif
 
814
  590   continue
 
815
        cdb0p = DCMPLX(DBLE(xx),DBLE(y))
 
816
        cdb0 = cdb0p*(1/DBLE(xp))
 
817
        goto 990
 
818
* -#]   normal case:
 
819
*  #] unequal nonzero masses:
 
820
*  #[ debug:
 
821
  990   continue
 
822
        if (lwrite) then
 
823
            print *,'cdb0  = ',cdb0,cdb0p
 
824
        endif
 
825
*  #] debug:
 
826
*###] ffxdbp:
 
827
        end