bromberg method compared with tanh-sinh and gauss-legendre methods



Comparison of bromberg method with the other
available bigfloat methods (see Ch.9)
for bigfloat quadrature of finite
domain integrals.

The other methods used here are
the tanh-sinh method (most useful for
end-point singularities) and the
gauss-legendre method (generally the
quickest once the needed method arrays
have been caculated for a given value
of fpprec (set to requested wp).

-------------------------------------
 Each test run using
   mcompare3(expr,x,x1,x2,rp,wp)
 used three independent bigfloat methods:

 1.) the tanh-sinh (ts) method,
 2.) the gauss-legendre (gs) method, and
 3.) the bromberg (br) method,
    (each method is discussed in
          Ch.9 of Maxima by Example).

 rp = minimum  requested precision of result,
 wp = working precision of arithmetic
      (locally fpprec is set to wp).

  Neither the gauss-legendre method
  nor the bromberg method is suitable
  for integrands with end-point singularities;
  the tanh-sinh method's power shows up for
  such cases, since the latter method stays
  away from the end points.



 Two types of integrals were considered
  for comparing bromberg with both the
  tanh-sinh and gauss-legendre methods:

 1. monotonic well-behaved function
       1/(1 + sqrt(x))
    over domain [1/2, 1]

 2. pure oscillation function
       sin(50*x) over [0, 1]

For each of these two integrand-domain choices,
runs were made with three parameter cases:

  1.)  rp = 20,  wp = 40
  2.)  rp = 40,  wp = 60
  3.)  rp = 80,  wp = 110

Each method, for each case printed out a line
such as:

  ts:   4.6672614583958563E-61    0.39

in which we have the items:

 method   abs(diff from the true val)    #sec

The function mcompare3 uses a global "true value",
bound to tval, to compute the difference number.

When focusing on the times required for each method
to return an answer, one needs to bear in mind that
both the tanh-sinh method and the gauss-legendre
method need to calculate method-arrays of numbers
related to the local value of fpprec being used.

Thus the first time either the tanh-sinh or
gauss-legendre method is used with a requested
value of wp, some extra time is needed.
After that first call, the calculation times
drop for each method (ts, gs).

The bromberg method has no initial extra time
at a given requested wp value.


(%i1) load(mcompare);
   _kmax% =  8   _epsfac% =  2
(%o1) "c:/work2/mcompare.mac"


 case: monotonic function  1/(1 + sqrt(x)),
           over domain [1/2, 1].

(%i2) intanalysis:false$
(%i3) integrate(1/(1+sqrt(x)),x,1/2,1);

(%o3) 2*log((sqrt(2)+2)/2)-2*log(2)-sqrt(2)+2
(%i4) tval : bfloat(%),fpprec:140;
(%o4) 
2.6909206998615507341183356137535683526014837806555698596787145083584102407286098999943626850361445035246134309158863015154274826082805499131b-1

   case rp = 20,  wp = 40

(%i5) mcompare3(1/(1+sqrt(x)),x,1/2,1,20,40)$
 construct _yw%[kk,fpprec] array for kk =
  8  and fpprec =  40   ...working...
 ts:   1.1479437019748901E-41    2.86
 gs:   0.0    0.56
 br:   4.9562023609215998E-26     0.15

(%i6) mcompare3(1/(1+sqrt(x)),x,1/2,1,20,40)$
 ts:   1.1479437019748901E-41    0.17
 gs:   0.0    0.03
 br:   4.9562023609215998E-26     0.09

(%i7) mcompare3(1/(1+sqrt(x)),x,1/2,1,20,40)$
 ts:   1.1479437019748901E-41    0.17
 gs:   0.0    0.01
 br:   4.9562023609215998E-26     0.1

(%i8) mcompare3(1/(1+sqrt(x)),x,1/2,1,20,40)$
 ts:   1.1479437019748901E-41    0.23
 gs:   0.0    0.03
 br:   4.9562023609215998E-26     0.08

 ----------------------------------------------
   similar test runs for the cases
     rp = 40   wp = 60
     rp = 80   wp = 110

   were then run.

=====================================================
Summaries with case: 1/(1 + sqrt(x)) over [1/2, 1]

 (wp = "working precision" = local value of fpprec)

=====================================================
 1.)  #sec for first time call with a given wp:

 rp     wp     tanh-sinh         gauss        bromberg

 20     40        2.9             0.6            0.15

 40     60        3.7             3.0            1.6

 80    110        6.6              15            117

 ========================================================
 2.)   #sec with same function called with a prev. used wp:

 rp     wp     tanh-sinh          gauss         bromberg

 20     40        0.19             0.02           0.1

 40     60        0.45             0.04           1.64

 80    110        1.02             0.12           117

 =======================================================

 3.)  after prev.use of a working precision wp,
            ratio of calc. times:

  rp   wp     gs/ts    gs/br

  20   40      0.1      0.2

  40   60      0.1      0.02

  80  110      0.1      0.001

=======================================================
 4.)  start-up (#sec) cost of a given wp
      with 1/(1 + sqrt(x) over [1/2, 1]

     start-up cost depends on the function
     and domain as well as value of wp
      for the gauss method

   wp       tanh-sinh       gauss

   40           2.7           0.6

   60           3.2           3

  110            6            15
========================================
========================================
   case pure oscillating function
        sin(50*x) over [0, 1]
========================================
RESTART MAXIMA, SO WP ARRAYS HAVE TO
BE RECALCULATED ON THE FIRST CALLS:

(%i1) load(mcompare);
   _kmax% =  8   _epsfac% =  2
(%o1) "c:/work2/mcompare.mac"

(%i2) integrate(sin(50*x),x,0,1);
(%o2) 1/50-cos(50)/50
(%i3) tval : bfloat(%),fpprec:140;
(%o3) 
7.0067943015773451862085882197966016159165449243876487824242006779788757529564800558931151053515534522575563305655524145012821980213213240117b-4

    case  rp = 20  wp = 40

(%i4) mcompare3(sin(50*x),x,0,1,20,40)$
 construct _yw%[kk,fpprec] array for kk =
  8  and fpprec =  40   ...working...
 ts:   9.4391464556919678E-42    3.84
 gs:   2.7032728934982911E-40    2.19
 br:   1.9960557541374238E-28     2.56

(%i5) mcompare3(sin(50*x),x,0,1,20,40)$
 ts:   9.4391464556919678E-42    1.15
 gs:   2.7032728934982911E-40    0.08
 br:   1.9960557541374238E-28     2.5

(%i6) mcompare3(sin(50*x),x,0,1,20,40)$
 ts:   9.4391464556919678E-42    1.21
 gs:   2.7032728934982911E-40    0.08
 br:   1.9960557541374238E-28     2.5

(%i7) mcompare3(sin(50*x),x,0,1,20,40)$
 ts:   9.4391464556919678E-42    1.16
 gs:   2.7032728934982911E-40    0.08
 br:   1.9960557541374238E-28     2.45

 similar test runs for the cases
     rp = 40   wp = 60
     rp = 80   wp = 110

  were then run.
===========================================
Summaries of oscillating function test
     sin(50*x) over [0, 1]
 =====================================================
 1.)  #sec for first time call with a given wp:

 rp     wp     tanh-sinh         gauss        bromberg

 20     40        3.8              2.2            2.5

 40     60        4.7             11.6           24

 80    110       11               15           1150

========================================================
 2.)   #sec with same function called with a prev. used wp:

 rp     wp     tanh-sinh          gauss         bromberg

 20     40        1.2             0.08           2.5

 40     60        1.5             0.2           24

 80    110        5               0.3           1150

======================================================
 3.)  after prev.use of a working precision wp,
            ratio of calc. times (sec):

  rp   wp     gs/ts      gs/br

  20   40      0.6        0.9

  40   60      0.1        0.008

  80  110      0.06       0.0003
=======================================================
 4.)  start-up (#sec) cost of a given wp
       with sin(50*x) over [0, 1]

          start-up cost depends on the function
     and domain as well as value of wp
      for the gauss method

   wp       tanh-sinh       gauss

   40           2.6           2.1

   60           3.2          11.4

  110            6            15
===================================================
Effectiveness of tanh-sinh method for end-point
singularities: see Ch.9 examples.
================================================

Overall results of these tests indicate that
the gauss-legendre method is generally the
fastest for repeated use at a given precision.

As the requested wp = working precision increases,
the start-up cost of calculating the needed method
arrays can cause the gauss-legendre method to
be slower the first time a new wp is used.

The bromberg method is much slower than either of
the other methods at higher values of requested wp.
--------------------------------------------

Ted Woollett