Richard Fateman fateman at cs.berkeley.edu
Sun Mar 1 12:18:18 CST 2009

```Robert:
I just came across this example, not for the first time,
but I thought I'd send it to you (and Maxima list)
to illustrate the problem and hope that you had an idea that could fix
it in a nice way.

let s(c):= (x^2+x+2)/(x^2+x+c);

Now consider integrate(s(c),x);

Maxima gives two possible answers depending on the sign of 4*c-1. call
them A(x,c) and B(x,c).
Mathematica gives only one answer, which corresponds to answering
"positive" and is equal to A(x,c).
In fact this is a bug in Maxima because it should provide yet a third
form of the answer for 4*c-1=0.
It is a bug in Mathematica, though they have traditionally denied it,
but may be trying to "fix" it.

Consider the questions of whether 2 forms that are supposed to be
identical are computationally identical.

bfloat(rectform(subst(x=1.0, subst(c=1/8, integrate(s(c),x)) =
integrate(s(1/8),x))));
bfloat(rectform(subst(x=1.0, subst(c=4,   integrate(s(c),x)) =
integrate(s(4),x))));

/* shows bug... bfloat(rectform(subst(x=1.0, subst(c=1/4,
integrate(s(c),x)) = integrate(s(1/4),x))));*/

These two examples in Maxima require that you answer a question, and the
alleged equation
is true only if you answer the question correctly. Try cutting from this
mail and pasting them in.

Conclusion: if you wish to interchange order of "integration" and
"substitution of values for parameters",
you need some answers about the range of the parameter(s), or you might
be disappointed.

Is there a way around this?  well, if the integration program were
required to produce a correct answer
for all values of c, it would have to return something roughly equivalent to

F: if c=1/4 then (x-7)/(4*x+2)
else if 4*c>1 then ((4-2*c)*atan((2*x+1)/sqrt(4*c-1)))/sqrt(4*c-1)+x
else
x-((c-2)*log((2*x-sqrt(1-4*c)+1)/(2*x+sqrt(1-4*c)+1)))/sqrt(1-4*c)

(and maybe some other answers if c is complex, but that doesn't change
the point of this note)

Then a challenge for Maxima is to notice that computing diff(F,x)
eliminates all the 'if's
and is simply s(c).

Now consider if s(c) involved more parameters. And perhaps iterated
integrals.
The theory of (several) complex variables is not computationally
comfortable.

Sam Dooley explored this a little in his MS project (Berkeley)
There are other possibilities like requiring or constructing contexts
with assumptions,
computing on Riemann surfaces, keeping track of branch cuts in
computations. There
is a small literature on this. e.g. work by Rob Corliss, Harlan Seymour
(Berkeley).
Probably a few others.

RJF

Robert Dodier wrote:
> On Tue, Feb 24, 2009 at 6:57 PM, rjf <fateman at gmail.com> wrote:
>
>
>> On Feb 24, 10:25 am, Robert Dodier <robert.dod... at gmail.com> wrote:
>>
>
>
>>> He and I agree that Macsyma's asksign makes life needlessly difficult.
>>>
>
>
>> Yes, but finding a GOOD solution is tough.  There are several examples
>> of bad solutions, and I have at least one MS student who constructed a
>> pretty good solution, but impractical when scaled up...
>>
>
> What was the pretty good solution?
>
>
>> For example, I think the Maple "language" is a terrible design.
>>
>
> Yeah, it's atrocious, from what I know of it.
>
> Robert
>

```