# [Maxima] numeric approximation

Edwin Woollett woollett at charter.net
Tue Feb 7 12:55:11 CST 2012

```On Feb. 7, 2012, Rupert Swarbrick wrote:
-----------------------------
>Notice that there are several numerical integration routines and that
>(as far as I know) clever numerical analyst types haven't found a way to
>automatically determine which one is most appropriate, so it's not clear
>how one would implement the "gimme_a_number" flag. Also, numerical
>routines also return a guess at their error, which you're throwing away
>in your code above. How should that be treated by the "gimme_a_number"
>flag?
-----------------------------------
A "wrapper" for the quadpack routines is something I have been
diligently working on, as part of a software package for
an updated version of Ch. 8, Numerical Integration,
(Maxima by Example).

The one-dimensional quadrature code is basically done,
and I am now trying to integrate two dimensional
code into the package.

This code first tries integrate to get an exact
symbolic answer (if possible). Due to some bugs
in the special functions area, there are automatic
filters to bypass integrate and go directly to
quadpack (this also includes multiple valued
functions case).

The code then chooses between the quadpack routines
using a variety of methods and option flags.

If quadpack returns a serious error code, the function
nint will return 'false' together with a plain English
error message.

The one and two dimensional versions of nint are tested
with all the demonstration numerical integrals posted
by Mathematica, together with a variety of integrals
that need to be checked because of various Maxima
peculiarities.

The particular example Olive has submitted can then
be handled as follows:

-----------------------------------------------------
Maxima 5.26.0 http://maxima.sourceforge.net
using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (a.k.a. GCL)

(%o1) "c:/work2/nint.mac"

(%i2) g : 1/(sin(x)^2 + log(x))\$

(%i3) f(t) := nint(g,x,1,t)\$

(%i4) f(5);

(%o4) 2.729767710374242

(%i5) goutL;

(%o5) [[qag,2.729767710374242,3.3769724748722686E-12,93,0]]
--------------------------------------
Ted Woollett

http://www.csulb.edu/~woollett/

```