7.135 Bug in value in Maple V.5 (28.3.99)

7.135.1 Steve Thomason
7.135.2 Bob Jantzen (29.3.99)
7.135.3 Bernard Marcheterre (30.3.99)
7.135.4 Joe Riel (6.4.99)
7.135.5 HARALD PLEYM (16.4.99)

7.135.1 Steve Thomason

> kernelopts(version); 
Maple V, Release 5, IBM INTEL NT, Nov 27 1997, WIN-55CD-314159-2 
 
> restart; 
> problem := Int( Int( 5*x-2*y, y=0..1 ), x=0..1); 
      problem := Int(Int(5*x-2*y,y = 0 .. 1),x = 0 .. 1) 
 
> incorrect := value(problem); 
      incorrect := 5/2-2*y 
 
> correct := simplify(subs(Int=int,problem)); 
      correct := 3/2
 

It is corrected with Maple 6. (U. Klein)

7.135.2 Bob Jantzen (29.3.99)

I am using MAPLE 5.0 for Windows (patchlevel 1) on a WIN95 machine and cannot figure out why my evaluation (using "value") of triple integrals in unevaluated form ("Int" rather than "int") is not working in some examples.

>  restart: 
> Int(Int(Int(x*y*z,z=0..1-x-y), y=0..1-x),x = 0..1); 
> value(%); 
     1/120 * z
 

It does not do the innermost integration correctly but just treats the whole integrand as a constant and uses that constant times z as the antiderivative into which it plugs in the limits, leaving the original function of all 3 variables as a factor after that integration step is performed:

> Int(Int(x*y*z*(1-x-y-0), y=0..1-x),x = 0..1); 
> value(%); 
     1/120 * z
 

No Maple help page that I know of actually suggests that this should work, so I cannot call this a mistake.

However, it is advertized to work with the student package command Tripleint in its help page, but fails in the same way:

> with(student): 
> Tripleint(x*y*z,z=0..1-x-y, y=0..1-x,x = 0..1); 
> value(%); 
     1/120 * z
 

This also fails when using the vec_calc package of Belmonte and Yasskin, CalcLabs with Maple for Stewart's Multivariable Calculus: Concepts and Contexts, Chapter 5 if one uses their multiple integral command Muint, followed by value for this same example, as they indicate should work in their help page.

> restart: 
> libname := libname, `F:\\depart\\math\\maple\\vec_calc`: 
                      # local address of vec_calc files 
> with(vec_calc): 
> vc_aliases: 
> Muint(x*y*z,z=0..1-x-y, y=0..1-x,x = 0..1); 
> value(%); 
     1/120 * z
 

I have done some other triple integrals with limits which are not contants and this works correctly (as one would expect, contrary to my example). And the noninert int commands all work correctly in this example.

Can anyone enlighten me? Am I doing something really stupid? This is really puzzling me.

7.135.3 Bernard Marcheterre (30.3.99)

This might have been reported by someone else. Lets make sure everyone knows unless, quite possibly, I’m the one that does not understand.

Try this;

>with(student): 
>a:=Doubleint(x+y,x=0..2,y=0..2): 
value(a);
 

With the last line you get:

4*x+4
 

Which, I guess, is not right?

With:

evalf(a):
 

Maple answers:

8

Which is more on line....

7.135.4 Joe Riel (6.4.99)

Several people submitted examples where Maple’s value procedure incorrectly evaluated inert multiple integrals. The problem is that the nested functions are not evaluated from the inside out. I found this quite some time ago when trying to figure out just how inert functions of any sort are evaluated in R5; it’s different than in R4.

For reasons that I do not understand, the `eval/Int` procedure for R5 calls two separate procedures, one for definite integrals and another for indefinite integrals. I believe that both are flawed, but forget the details (maybe it is simply the eval/Int procedure that is flawed). Somewhat amazingly, the following "simple" procedure appears to fix the bug.

I haven’t added it to my list of patches because I’m not sure that it is robust; however, it works for these problems. It also makes more sense, to me, than the original Maple procedures, though its operation is subtle [read confusing].

> `eval/Int` := evalinertfunc: 
> value(Int(Int(5*x-2*y,y = 0 .. 1),x = 0 .. 1)); 
 
 
                                 3/2 
 
> value(Int(Int(Int(x*y*z,z=0..1-x-y), y=0..1-x),x = 0..1)); 
 
 
                                1/720 
 
> value(student[Tripleint](x*y*z,z=0..1-x-y, y=0..1-x,x = 0..1)); 
 
 
                                1/720 
 
> value(student[Doubleint](x+y,x=0..2,y=0..2)); 
 
 
                                  8
 
#%----------------evalinertfunc---------------------- 
#% 
# \begin{Proc}{evalinertfunc} 
# Evaluate an inert function. 
# This function is intended to be assigned to a global variable 
# `"eval/"\Func`, where \Func{} is the inert function that is to 
# be evaluated. 
# Once so assigned it will be called by the Maple procedure 
# "value" when it is evaluating \Func. 
# The arguments to \Func{} are evaluated and then passed to 
# the active version of \Func{}. 
# 
# The first parameter, "e", is passed the inert function call that is 
# being evaluated, for example, $\Func(x_1,x_2,x_3)$.  The second 
# parameter, "eqs", is passed a set of equations that equate the inert 
# functions in "e" (and possibly some others) with their active 
# equivalents.  It should contain at least the equation 
# $\Func = `"value/"\Func`$. 
# 
# \begin{commentary} 
#     The implementation is a bit weird, 
#     Rather than just extracting and evaluting the arguments 
#     (harder to do then it appears), the call to 
#     "eval" is delayed (so that it works correctly). 
#     Evaluation of the arguments really takes place 
#     after the new function is assembled. 
# \end{commentary} 
 
evalinertfunc := proc(e, eqs) 
option `Copyright (c) 1998 by Joseph Riel. All rights reserved.`; 
description "Evaluate an inert function"; 
    eval(subsop(0=eval(op(0,e),eqs), map(''eval'',e,eqs))) 
end: 
 
# \end{Proc}
 

7.135.5 HARALD PLEYM (16.4.99)

| Joe Riel wrote: ...

Joe’s comment "The problem is that the nested functions are not evaluated from the inside out" inspired me to do some experiments. And the following works:

Expand the multiple integral before using the value command. But please note that you have to load the student package before using expand, because the expand command behave different with and without loading the package.

A:=Int(Int(Int(x+y*z,x = 0 .. y),y = 0 .. z^2),z = 0 .. 1); 
                              2 
                        1    z     y 
                       /    /     / 
                      |    |     | 
                A :=  |    |     |   x + y z dx dy dz 
                      |    |     | 
                     /    /     / 
                       0    0     0 
 
> expand(A); 
 
                            2 
                      1    z     y 
                     /    /     / 
                    |    |     | 
                    |    |     |   x + y z dx dy dz 
                    |    |     | 
                   /    /     / 
                     0    0     0 
> with(student): 
> expand(A); 
 
                                     1       2 
              2                     /       z 
        1    z     y               |       /        y 
       /    /     /                |      |        / 
      |    |     |                 |      |       | 
      |    |     |   x dx dy dz +  |   z  |    y  |   1 dx dy dz 
      |    |     |                 |      |       | 
     /    /     /                  |      |      / 
       0    0     0                |     /         0 
                                   |       0 
                                  / 
                                    0 
> A=value(expand(A)); 
 
                         2 
                   1    z     y 
                  /    /     / 
                 |    |     |                       11 
                 |    |     |   x + y z dx dy dz = --- 
                 |    |     |                      168 
                /    /     / 
                  0    0     0 
 
> A:=Int(Int(5*x-2*y,y = 0 .. 1),x = 0 .. 1): 
> A=value(expand(A)); 
                      1    1 
                     /    / 
                    |    | 
                    |    |   5 x - 2 y dy dx = 3/2 
                    |    | 
                   /    / 
                     0    0 
 
> A:=Int(Int(Int(x*y*z,z=0..1-x-y), y=0..1-x),x = 0..1): 
> A=value(expand(A)); 
 
             1    1 - x    1 - x - y 
            /    /        / 
           |    |        | 
           |    |        |           x y z dz dy dx = 1/720 
           |    |        | 
          /    /        / 
            0    0        0 
 
> A:=Tripleint(x*y*z,z=0..1-x-y, y=0..1-x,x = 0..1): 
> A=value(expand(A)); 
 
             1    1 - x    1 - x - y 
            /    /        / 
           |    |        | 
           |    |        |           x y z dz dy dx = 1/720 
           |    |        | 
          /    /        / 
            0    0        0 
 
> A:=Doubleint(x+y,x=0..2,y=0..2): 
> A=value(expand(A)); 
 
                         2    2 
                        /    / 
                       |    | 
                       |    |   x + y dx dy = 8 
                       |    | 
                      /    / 
                        0    0