Subject: More Integrals for the Exponential function
From: Dieter Kaiser
Date: Mon, 10 Nov 2008 23:36:57 +0100
I have build up a testfile with about 730 integrals for the exponential
functions. Maxima can solve 240 of these integrals. These integrals are not all
of different types but are more and more general.
In a first step I have added code to support about 200 extra integrals. I needed
8 general patterns for these integrals.
But now I have detected a problem with the pattern match mechanism of schatchen
in schatc.lisp.
It is necessary to match something like
A*X^P + B*X^Q + C*X^2 + ...
This expression contains exponents which are a variable. The problem is that it
is not possible to build up a general pattern with schatchen wich would match
such an expression correctly.
To match an exponent with a variable we would write something like
((mexpt) (X varp) (E freevar))
The variable E can contain all values like P, Q or a number like 2. By analyzing
the expression schatchen first match E with P, then with Q and at last with the
number 2. At the end we get a wrong match with wrong coefficients.
I have tried to find a workaround. At the end I have decided that it is a
missing feature of schatchen to recognize that we have an expression with
different and variable exponents.
Other code of Maxima has similar problems. I remember a bug in hypgeo.lisp which
depends on this behaviour of schatchen to handle exponents.
Perhaps it is possible to add a more correct handling of exponents to schatchen.
The routine where the exponents are handled is ZEPOW.
Perhaps I do something wrong.
An example for a simple pattern which can be loaded into Maxima to test
different expressions:
;;; Recognize a*x^r+c
(defun $m2_test1 (exp var*)
(declare (special var))
(setq var var*)
(let ((w
(m2 exp
'((mplus)
((coeffpt) (a freevar) ((mexpt) (x varp) (r freevar0)))
((coeffpp) (c freevar)))
nil)))
(format t "RESULT: ~A~%" w)
'done))
For this example the pattern is written:
(%i20) m2_test1(a*x^r+c,x);
RESULT: ((C . $C) (A . $A) (R . $R) (X . $X))
(%o20) done
We add a second power function with a different exponent. The match does not
fail as expected, but give a wrong answer. If we use the coefficients schatchen
has found we get the wrong result (a+b)*x^r+c.
(%i21) m2_test1(a*x^r+b*x^q+c,x);
RESULT: ((C . $C) (A (MPLUS SIMP) $A $B) (R . $R) (X . $X)
(R . $Q) (X . $X))
(%o21) done
We add again a term. The coefficients schatchen has wrongly found would give the
wrong match (a+b+1)*x^r+c.
(%i22) m2_test1(a*x^r+b*x^q+x^2+c,x);
RESULT: ((C . $C) (A (MPLUS SIMP) 1 $A $B) (R . $R) (X . $X)
(R . $Q) (X . $X) (R . 2) (X . $X))
(%o22) done
The only way to get correct answers is to specialize the pattern to match
exactly a*x^r+c and nothing else. But than we have to write an extra pattern for
every small variation like a*x^r+b*x^r. Thus instead of one general pattern for
a large number of integrands you have to write a large number of patterns for
every small change in the integrand.
Dieter Kaiser