List Archives > 
Maple User Group List Archive > 
Archive by date > 
This Month By Date > 
This Month By Topic
[MUG] testeq
| [MUG] testeq |
|
Author: Bill Whiten
Posted: 16/08/2001 07:13:07 GDT
|
>> From: (Bill Whiten)
In Maple Vr5.1 Mac:
> ex1:=n*k!/n!/(k-n)!*p^n*(1 - p)^(k-n);
n (k - n)
n k! p (1 - p)
ex1 := ----------------------
n! (k - n)!
> ex2:=k*(k-1)!/(k-n)!/(n-1)!*p^(n-1)*(1 - p)^(k-n)*p;
(-1 + n) (k - n)
k (k - 1)! p (1 - p) p
ex2 := -------------------------------------
(k - n)! (-1 + n)!
> testeq(ex1,ex2);
false
> simplify(ex1-ex2);
0
> simplify(ex1/ex2);
1
>
-----------
Bill Whiten,
Julius Kruttschnitt Mineral Research Centre,
The University Of Queensland, Tel: int +61 7 3365 5888
Isles Rd, Indooroopilly, Fax: int +61 7 3365 5999
Brisbane Qld 4068, AUSTRALIA.
|
| [MUG] Re: testeq |
|
Author: Maple User Group
Posted: 22/08/2001 16:11:03 GDT
|
>> From: Maple User Group
|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
To:
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
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
To:
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.
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Sun, 19 Aug 2001 16:24:13 +0100 (BST)
From: J H Davenport
To:
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
To:
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
|
| [MUG] Re: testeq |
|
Author: Carl DeVore
Posted: 23/08/2001 20:53:48 GDT
|
>> From: Carl DeVore
> Date: Tue, 21 Aug 2001 11:02:23 +0200
> From: Helmut Kahovec
>
> 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()
> to
> 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)
My assumption is that the testeq command was intended to be used on
expressions that would take a very long time to simplify.
|
Previous by date: [MUG] Re: Bell command, Helmut Kahovec
Next by date: [MUG] labelling on plots, Richard Patterson
Previous thread: [MUG] Some Algebraic Manipulations with Radicals, Les Wright
Next thread: [MUG] labelling on plots, Richard Patterson
|