The following example was shown to me by Matthias Kawski.

He noticed a difference in the way Maple 12 handles some definite integrals from the way they were done in Maple 8. Both cases point out some problems. I'll offer my explanation of the problem after I show what Matthias observed: First, the results from Maple 8. Each of these 4 examples evaluates a definite integral in two different ways, the first using a function and the second using an expression. All looks fine until the last example.

 

----------------------------------------------------------

MAPLE 8

> restart;
> f:=t->sin(t)
> int(f,0..Pi);
> int(f(x),x=0..Pi);

2

2

> f:=t->sin(3*t):
> int(f,0..Pi);
> int(f(x),x=0..Pi);

2/3

2/3

> f:=t->sin(Pi*t):
> int(f,0..1);
> int(f(x),x=0..1);

2
----
Pi

2
----
Pi

> f:=t->sin(3*Pi*t):
> int(f,0..1);
> int(f(x),x=0..1);

2
----
Pi

2
----
3 Pi

----------------------------------------------------------

Now, the same examples in Maple 12. Now there are problems in the second and fourth examples.

----------------------------------------------------------

MAPLE 12

restart;
f:=t->sin(t):
int(f,0..Pi);
int(f(x),x=0..Pi);

2

2

f:=t->sin(3*t):
int(f,0..Pi);
int(f(x),x=0..Pi);

2

2
-
3

f:=t->sin(Pi*t):
int(f,0..1);
int(f(x),x=0..1);

2
--
Pi

2
--
Pi

f:=t->sin(3*Pi*t):
int(f,0..1);
int(f(x),x=0..1);

2
--
Pi

2
----
3 Pi

----------------------------------------------------------

These are not difficult integrals. Why does Maple have so much trouble with the integrands that are expressed as functions and not when the integrand is an expression?

I believe the problem is in the remember table, and the way in which the functional arguments are handled. The problem disappears if each function has a different name. It also disappears if each example starts with a restart;.

When Maple sees f(x), it evaluates to the function definition. Each of the the f(x) integrands looks different to Maple, so it evaluates each one when it is encountered. But, when the integrand is passed as a function name, f, that's all that Maple sees. After the first one, the result is placed into Maple's remember table. The subsequent calls see that this result has already been computed and simply returns that result.

This is not the complete story, as some of the results are different when the order of the tests is changed. In spite of this, I stand by my diagnosis that this has something to do with the way a function name is not expanded and the use of remember tables.

Further explanations, and corrections, are appreciated.

Doug


Please Wait...