Maxima by Example, Chapter 8: Numerical Integration

Ted Woollett

The newly revised chapter 8 includes new package functions nint, quad, mdefint, and ndefint for 1d and 2d numerical integration, available after loading the file nint.mac.

The new package loaded by apnint.mac (nint.mac should be loaded first) makes available two functions for arbitrary precision quadrature in 1 dimension, apnint and apquad.

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:

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.

Arbitrary precision quadrature using apnint has the syntax
in which rp is the requested precision of the answer, and wp is the working precision. The function apnint first tries using integrate, if feasible, and if not successful, uses one of two numerical methods we discuss in Ch.9.

The function apquad has the same syntax:

and avoids integrate, forcing use of one of two possible numerical methods.

In both of these arbitrary precision cases, if the domain is non-finite, then x1 should be finite and x2 should be the symbol inf.

  1. : Dec. 14, 2013 zip code of all Ch. 8 files
  2. --mbe8nint.tar.gz : Dec. 14, 2013 tar.gz code of all Ch. 8 files
  3. --mbe8nint.pdf : 11/16/2012, Maxima 5.28.0, 35 page pdf file
  4. --mbe8nint.tex : 11/16/2012, Maxima 5.28.0, Latex code file
  5. --mbe8code.txt : Copy and Paste Code: 11/16/2012, Maxima 5.28.0
  6. --nint.mac Dec. 14, 2013, Maxima 5.28.0
  7. --nint.lisp Oct. 31,2012, Maxima 5.28.0
  8. --mydefint.mac Oct. 31,2012, Maxima 5.28.0
  9. --quad1d.mac Oct. 31,2012, Maxima 5.28.0
  10. --quad2d.mac Oct. 31,2012, Maxima 5.28.0
  11. --quad_util.mac Oct. 31,2012, Maxima 5.28.0
  12. --nint_test.mac Oct. 31,2012, Maxima 5.28.0
  13. --apnint.mac Dec. 14, 2013, Maxima 5.28.0
  14. --dequad.mac 11/16/2012, Maxima 5.28.0
  15. --tsquad.mac Dec. 14, 2013, Maxima 5.28.0

Chapter 8 Topics

  1. Using nint and quad for One or Two Dimensional Quadrature
  2. Using apnint and apquad for Arbitrary Precision Quadrature
  3. Using the Wolfram Alpha Web Site for Integrals
  4. Direct Quadpack Use of quad_qags, quad_qag, and quad_qagi
  5. Sharper Tools: Use of quad_qagp, quad_qawo, quad_qaws, quad_qawc, and quad_qawf
  6. Numerical Integration Decision Trees