Revised ch. 8 Numerical Integration (Maxima by Example)



The revised Ch. 8, Numerical Integration (Maxima by Example) has been
posted at my Cal State Long Beach webpage. All references to romberg have
been deleted. The new nint package  provides a simple interface to 1d and
2d quadrature, making use of both integrate (if feasible) and the
Maxima quadpack functions.

I would like to thank the Maxima developers for their friendly help via
 the Maxima mailing list. Richard Fateman provided early encouragement and
advice. Raymond Toy, Stavros Macrakis, and Barton Willis have each
contributed importantly to the evolution of the code in the nint package.

The present nint package is a work in progress, partially dictated by
the progress in Maxima special function float values. Extension to
user-requested accuracy depends on development of arbitrarily accurate
evaluations of Maxima special functions, as well as augmentation of
the present quadpack quadrature routines with algorithms which can
use bigfloat methods.

>From the current webpage:
=============================================
Chapter 8: Numerical Integration

The newly revised chapter 8 includes new package functions
 nint, quad, mdefint, and ndefint for 1d and 2d numerical integration.

For routine 1d numerical integration (quadrature), you can simply
 use the syntax:

    nint (expr,x,x1,x2)

where expr can be either real or complex. The new function nint
 will first try the Maxima function integrate (if feasible),
 and if not successful, will use the Maxima quadpack functions.
 You can force Maxima to just use the quadpack functions with the syntax:

    quad (expr,x,x1,x2),

again with expr being either real or complex.

You can also force Maxima to try integrate (if nint avoids integrate
 for a given integrand-domain) by using the syntax:

    mdefint (expr,x,x1,x2)

for a symbolic answer, and

    ndefint (expr,x,x1,x2)

for a numerical answer calculated from the symbolic integrate answer
 using bigfloat methods with 32 digit precision.

The 2d syntax is similar to Mathematica's:

    nint(f,[x,x1,x2],[y,y1,y2])

is an approximate numerical value of

    integrate( integrate (f,y,y1,y2), x,x1,x2).

A number of optional arguments can be used to control or request the 
quadpack method to be used.

    --mbe8nint.zip : Nov.1,2012 zip code of all Ch. 8 files
    --mbe8nint.tar.gz : Nov.1,2012 tar.gz code of all Ch. 8 files
    --mbe8nint.pdf : Nov.1,2012, Maxima 5.28.0, 30 page pdf file
    --mbe8code.txt : Copy and Paste Code: Oct. 31,2012, Maxima 5.28.0
    --nint.mac Nov.1,2012, Maxima 5.28.0
    --nint.lisp Oct. 31,2012, Maxima 5.28.0
    --mydefint.mac Oct. 31,2012, Maxima 5.28.0
    --quad1d.mac Oct. 31,2012, Maxima 5.28.0
    --quad2d.mac Oct. 31,2012, Maxima 5.28.0
    --quad_util.mac Oct. 31,2012, Maxima 5.28.0
    --nint_test.mac Oct. 31,2012, Maxima 5.28.0

Chapter 8 Topics

    Using nint and quad for One or Two Dimensional Quadrature
    Using the Wolfram Alpha Web Site for Integrals
    Direct Quadpack Use of quad_qags, quad_qag, and quad_qagi
    Sharper Tools: Use of quad_qagp, quad_qawo, quad_qaws, quad_qawc, and 
quad_qawf
    Numerical Integration Decision Trees

SOME EXAMPLES OF USE:
================================================
Maxima 5.28.0-2 http://maxima.sourceforge.net
using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (a.k.a. GCL)


(%i1) load(nint);
(%o1) "c:/work7/nint.mac"
(%i2) quad(cos(cos(x)),x,0,1);
(%o2) 0.65978105360122
(%i3) nint(cos(cos(x)),x,0,1);
(%o3) 0.65978105360122
(%i4) noutL;
(%o4) [qags,0.65978105360122,7.3250411691952122E-15,21,0]
(%i5) method:true$
(%i6) nint(cos(cos(x)),x,0,1);
   quad_qags
(%o6) 0.65978105360122
(%i7) nint(log(1/x)/sqrt(x),x,0,1);
   quad_qags
(%o7) 3.999999999999997
(%i8) mdefint(log(1/x)/sqrt(x),x,0,1);
(%o8) 4
(%i9) ndefint(log(1/x)/sqrt(x),x,0,1);
(%o9) 4.0
(%i10) ndefint(log(1/x)/sqrt(%i*x),x,0,1);
(%o10) 2.82842712474619-2.82842712474619*%i
(%i11) nint(x^x,x,1,5);
   quad_qag
(%o11) 1241.033284049404
(%i12) quad (1/sqrt(x),[x,0,1],[y,0,1],real);
  qags2
(%o12) 2.0
(%i13) ndefint(log(y)/x^(4/5),[x,0,1],[y,0,1]);
(%o13) -5.0
(%i14) quad(log(y)/x^(4/5),[x,0,1],[y,0,1]);
  qags2
(%o14) -5.000000000000004
(%i15) nint(log(2-sin(x)-sin(y)),[x,0,4],[y,0,4],real);
  qags2
(%o15) -2.419076183610292
(%i16) nint(sqrt(log(x-7)),x,0,20,points(7,8));
 quad_qagp
  quad_qagp
  quad_qagp
(%o16) 8.560652564685467*%i+25.88167817088944
(%i17) quad(exp(-abs(x)),x,1,inf);
 quad_qagi
(%o17) 0.36787944117144
(%i18) quad(log(1/x)/sqrt(%i*x),x,0,1);
   quad_qags
   quad_qags
(%o18) 2.82842712474623-2.828427124746158*%i
(%i19) quad(log(1/x)/sqrt(%i*x),x,0,1,singular);
 quad_qags
(%o19) 2.82842712474623-2.828427124746158*%i
(%i20) nint(bessel_j(1,x),x,1,10^4);
  quad_qag
(%o20) 0.77229384691157
(%i21) time(%);
(%o21) [60.04]
(%i22) nint(bessel_j(1,x),x,1,10^4,real,strong_osc);
 quad_qag
(%o22) 0.77229384691157
(%i23) time(%);
(%o23) [19.18]
(%i24) method:false$
(%i25) mquad(cos(cos(x)),x,0,1);
 mdefint:  'integrate(cos(cos(x2627212)),x2627212,0,1)
 quad:  0.65978105360122
 nint:  0.65978105360122
(%o25) 0.65978105360122
============================
Ted Woollett
http://www.csulb.edu/~woollett/