use oddfun in integrals?



2009/4/14 Martin Sch?necker <ms_usenet at gmx.de>:

> Is there a way to use the fact that a function is odd in the evaluation
> of an integral?

integrate doesn't seem to know about odd functions.
How about this? Define a pattern-matching rule to look
for the integral of an odd function over a symmetric interval.

(%i2) oddfunp (e) := atom(e) and featurep (e, oddfun);
(%o2) oddfunp(e):=atom(e) and featurep(e,oddfun)
(%i3) matchdeclare (oo, oddfunp, xx, symbolp);
(%o3) done
(%i4) matchdeclare (aa, all, bb, equal(-aa));
(%o4) done
(%i5) 'integrate (oo (xx), xx, aa, bb);
(%o5) 'integrate(oo(xx),xx,aa,bb)
(%i6) defrule (r1, ''%, 0);
(%o6) r1:?marrow('integrate(oo(xx),xx,aa,bb),0)
(%i7) integrate (foo (u), u, - a, a);
(%o7) 'integrate(foo(u),u,-a,a)
(%i8) apply1 (%, r1);
(%o8) 'integrate(foo(u),u,-a,a)
(%i9) declare (foo, oddfun);
(%o9) done
(%i10) integrate (foo (u), u, - a, a);
(%o10) 'integrate(foo(u),u,-a,a)
(%i11) apply1 (%, r1);
(%o11) 0

Hope this helps,

Robert Dodier