Hi.
On Thu, 12 Jan 2012, Constantine Frangos wrote:
> (1) Its not clear why the function definition I am using does not
> work. According to the Maxima 5.24 manual, paragraph 20.4, the
> integrand can be the name of a Maxima function, presumably defined by
> the user in a file, for example, integrand.mac
Your function does not always return a number. Consider your original
definition:
(%i1) ind(x,y) := block([s],if is(x*x + y*y <= 1) then (s : 1) else (s : 0),return(s))$
Let us see how it works
(%i2) trace(ind);
(%o2) [ind]
If one gives numerical arguments, then your function returns the
number which is assigned to "s"
(%i3) ind(0,1);
1 Enter ind [0, 1]
1 Exit ind 1
(%o3) 1
but with symbols as arguments nothing is assigned to "s" and thus the
function returns just a symbol "s"
(%i4) ind(x1,x2);
1 Enter ind [x1, x2]
1 Exit ind s
(%o4) s
and this is exactly what happens when you use it in integration
(%i5) I:quad_qags(quad_qags(ind(x1,x2),x1,-1,1)[1],x2,-1,1);
1 Enter ind [x1, x2]
1 Exit ind s
COERCE-FLOAT-FUN: no such Lisp or Maxima function: s
-- an error. To debug this try: debugmode(true);
> (2) Are there perhaps other Maxima numerical integration functions
> that may perform better ?
As I said, it is better to
> > use a simple integral:
> >
> > (%i4) quad_qags(2*sqrt(1-y^2),y,-1,1);
> > (%o4) [3.141592653589797, 2.000470900043183e-9, 399, 0]
the problem with indicators is that while they may be suitable for
symbolic manipulations, they are bad functions for Gaussian quadrature
rule which is only good if the function is similar to a polynomial.
--
Regards,
ASK