List Archives > 
Maple User Group List Archive > 
Archive by date > 
This Month By Date > 
This Month By Topic
[MUG] Re: Curious simplification
| [MUG] Re: Curious simplification |
|
Author: Greg Gamble
Posted: Fri, 13 Dec 2002 10:48:19 +0800
|
>> From: "Greg Gamble" "gregg"
On Wednesday, 11 December 2002 2:37 PM, Carl Devore wrote:
> On Thu, 5 Dec 2002, Greg Gamble wrote:
> > ... so this suggests using {solve(...)} to compare such expressions.
> > However, if one tries this with <> one gets:
> > > solve(x<>2);
> > x
> > (which means `any value' as I interpret it) and differs from:
> >
> > > solve(x < 2 or x > 2);
> > RealRange(-infinity, Open(2)),
> RealRange(Open(2), infinity)
>
> Because of complex numbers, 'x<>2' is not the same as 'x>2 or x<2'.
Thanks Carl ... I keep forgetting about Complex Numbers!!
After sending the email, I found that by defining a function
SolveInequality, I could map inequality expressions (of the type I was
expecting from students) uniformly to a set of RealRange expressions. My
function, however, replaced
expressions of form 'x <> a' by their 'x < a or x > a' equivalent,
explicitly,
by a call to a ReplaceNEQ function I defined. ...
> But if you include a trivial directional inequality in the solve, it will
> "reduce" the inequalities:
>
> > solve( {x<>2, x<infinity} );
> {x<2}, {2<x}
... Thus my code, of course, had precisely the sort of implied assumption
that Maple tries to avoid (I assumed I was working over the Real numbers).
So
I really should define a function SolveRealInequality (instead of
SolveInequality)
defined as follows:
SolveRealInequality := proc(ineq::boolean, var)::set;
description
"Returns the solution of the inequality ineq as a set of ",
"RealRange expressions";
local i;
{ seq( solve( op(i) ),
i = { solve({subs(var = `x`, ineq), x < infinity}) }
) };
end;
In this way, SolveRealInequality returns a canonical representation for
equivalent inequalities representing Real intervals, e.g.
> SolveRealInequality(x<>2, x);
{RealRange(-infinity, Open(2)), RealRange(Open(2), infinity)}
> SolveRealInequality(x>2 or x<2, x);
{RealRange(-infinity, Open(2)), RealRange(Open(2), infinity)}
> SolveRealInequality(2>x or 2<x, x);
{RealRange(-infinity, Open(2)), RealRange(Open(2), infinity)}
... so that seems to achieve what I was after (the first arguments of each
of these when tested pairwise for equality, Maple returns false).
However, there really seems to be a bug (I am using Maple 7) ...
> solve(x<2 or x>2 or x=2);
RealRange(-infinity, Open(2)), RealRange(Open(2), infinity)
whereas:
> solve(x<=2 or x>2);
x
Is there a reason for this behaviour? I'm a little troubled also by the
return
of x here also. It's not documented anywhere that I can see, what it's
supposed
to mean ... even looking through the code of `solve` there is no comment
indicating the reason for this return value. I interpret it as `any x', i.e.
`no restriction
on x', but if that's the case why do you also get ...
> solve(x<>2);
x
? I don't find this sensible. Can someone please explain it?
Regards,
Greg Gamble
// Greg Gamble, Dept. of Maths & Stats //
// Curtin University, Bentley WA 6102 //
// Mailto: "gregg" //
// WWW: http://www.maths.curtin.edu.au/~gregg //
|
[View Complete Thread]
Previous by date: [MUG] Re: Logplot to file, Robert Israel
Next by date: [MUG] Re: Evaluation problem, Maple User Group
Previous thread: [MUG] Two bugs in evalapply(), Helmut Kahovec
Next thread: [MUG] Evaluation problem, Colin Campbell - IST
|