nintegrate - second attempt



On 5/24/07, Barton Willis <willisb at unk.edu> wrote:
> Maybe you could extract the real and imaginary parts of the
> integrand before sending each piece to coerce-float-fun.
>
> This won't always work; rectform(asin(x)) asks about the sign
> of (x-1)*(x+1). That's OK if the integration interval is
> say [0,1], but it's not OK if the interval is [0,2].

Another version is now at http://wxmaxima.sf.net/nintegrate.lisp . It
has nint_complex option. If nint_complex is true there are a lot of
sign questions so I set it to false by default.

(%i1) nintegrate(x*%i, x, 0, 1);
(%o1) nintegrate(%i*x,x,0,1)
(%i2) nintegrate(x*%i, x, 0, 1), nint_complex=true;
(%o2) 0.5*%i
(%i3) nintegrate(asin(x), x, 2, 3);
(%o3) nintegrate(asin(x),x,2,3)
(%i4) nintegrate(asin(x), x, 2, 3), nint_complex=true;
(%o4) 1.5707963267949-1.5579494110903*%i

This version is now a regular function defined with defmfun, but it
still returns unevaluated if it does not find the numerical value.
This can easily be changed so that it produces an error if this
behavior is not acceptable.

HTH,
-- 
Andrej