List Archives > 
Maple User Group List Archive > 
Archive by date > 
This Month By Date > 
This Month By Topic
[MUG] Re: testeq
| [MUG] Re: testeq |
|
Author: Maple User Group
Posted: 22/08/2001 16:11:03 GDT
|
>> From: Maple User Group "maple_gr"
|On Thu, 16 Aug 2001, Bill Whiten wrote:
|> In Maple Vr5.1 Mac:
|>
|> > ex1:=n*k!/n!/(k-n)!*p^n*(1 - p)^(k-n);
|> > ex2:=k*(k-1)!/(k-n)!/(n-1)!*p^(n-1)*(1 - p)^(k-n)*p;
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Fri, 17 Aug 2001 15:16:20 -0700 (PDT)
From: Robert Israel "israel"
To: "maple-list"
Subject: testeq
This bug seems to be fixed in Maple 6, to the extent that the result is
FAIL rather than "false". Note that the help for testeq does not mention
factorial:
- This function will succeed over expressions formed with rational constants,
independent variables, and I, combined by arithmetic operations,
exponentials, trigonometrics and a few others. It may also succeed with some
expressions involving radicals, Pi as an argument of trigonometrics, and
algebraic constants and functions. If the expressions do not fall in this
class, testeq returns FAIL. Testeq may also return FAIL if it cannot find an
appropriate modulus that works after seven trials.
So FAIL should be an acceptable result in this context. Still, it's
curious that Maple 6 does not come up with "true" here, because it does
produce "true" for testeq(k*(k-1)!, k!).
Robert Israel "israel"
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Fri, 17 Aug 2001 23:10:12 -0400 (EDT)
From: Carl DeVore "devore"
To: "maple-list" "W.Whiten"
Subject: testeq
You do not need such a complicated example to catch this bug. In Maple
5.1, try
> testeq(n*(n-1)!, n!);
and you still get "false".
There seems to be much flip-flopping among versions with how testeq
handles this expression. Maple 6 returns "true". Maple 7 returns "FAIL".
FAIL is not incorrect per se, but if Maple 6 can find the answer, why not
Maple 7?
The testeq command does not try to simplify the difference. Therefore, I
think that testeq is intended for expressions where the simplify command
would take too long.
To verify equality, first try simplifying the difference.
--
Carl Devore
Maple programs written for hire. Maple advisor for hire.
"devore"
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Sun, 19 Aug 2001 16:24:13 +0100 (BST)
From: J H Davenport "jhd"
To: "maple-list"
Subject: testeq
Maple 6 returns 'FAIL' for me, which is not the same as false.
The HELP for testeq in Maple 6 says:
This function will succeed over expressions formed with rational
constants, independent variables, and I, combined by arithmetic
operations, exponentials, trigonometrics and a few others. It may also
succeed with some expressions involving radicals, Pi as an argument of
trigonometrics, and algebraic constants and functions. If the expressions
do not fall in this class, testeq returns FAIL. Testeq may also return
FAIL if it cannot find an appropriate modulus that works after seven
trials.
A quick use of printlevel shows that it is the second case (no modulus)
which is happening, essentially because Maple is refusing to work out the
factorials (which are converted into Gamma) since the arguments are too
large.
James Davenport
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Tue, 21 Aug 2001 11:02:23 +0200
From: Helmut Kahovec "helmut.kahovec"
To: "maple-list"
Subject: testeq
Well, this weakness of testeq() is present in the Windows version of
MapleV/Release5.1, too. It can be easily removed by changing the third
and fourth source code line of testeq() from
testeq := proc(a, b)
local expr, e1, e2, i, ig, preverror, s, t;
1 if nargs = 1 and type(a,algebraic) then
2 expr := a
elif nargs = 1 and type(a,`=`) and type(op(1,a),algebraic)
and type(op(2,a),algebraic) then
3 expr := op(1,a)-op(2,a)
elif nargs = 2 and type(a,algebraic) and type(b,algebraic)
then
4 expr := a-b
else
5 ERROR(`invalid arguments`)
fi;
...
to
testeq := proc(a, b)
local expr, e1, e2, i, ig, preverror, s, t;
1 if nargs = 1 and type(a,algebraic) then
2 expr := a
elif nargs = 1 and type(a,`=`) and type(op(1,a),algebraic)
and type(op(2,a),algebraic) then
3 expr := simplify(op(1,a)-op(2,a))
elif nargs = 2 and type(a,algebraic) and type(b,algebraic)
then
4 expr := simplify(a-b)
else
5 ERROR(`invalid arguments`)
fi;
...
Then we get:
> restart;
> ex1:=n*k!/n!/(k-n)!*p^n*(1-p)^(k-n);
> ex2:=k*(k-1)!/(k-n)!/(n-1)!*p^(n-1)*(1-p)^(k-n)*p;
> testeq(ex1,ex2),testeq(ex1=ex2);
true, true
With kind regards,
Helmut
|
[View Complete Thread]
Previous by date: [MUG] Re: Using data from a spreadsheet, Maple User Group
Next by date: [MUG] Re: Text Parsing, Maple User Group
Previous thread: [MUG] Testing Random Procedure., Jason C Leach
Next thread: [MUG] Re: Text Parsing, Maple User Group
|