#7660: arithmetic with equations and inequalities confusing
-------------------------------------+-------------------------------------
Reporter: burcin | Owner: burcin
Type: defect | Status: needs_review
Priority: major | Milestone: sage-6.4
Component: symbolics | Resolution:
Keywords: inequality, | Merged in:
solver, maxima | Reviewers:
Authors: Burcin Erocal, | Work issues:
Ralf Stephan | Commit:
Report Upstream: N/A | 17c4e8ad25114508ca1f722f66b497b594bca595
Branch: public/7660 | Stopgaps:
Dependencies: |
-------------------------------------+-------------------------------------
Description changed by chapoton:
Old description:
> Equations and relations should behave like this:
> equations:
> * `(a==b) +-*/ c` same as:
> - `(a==b).add_to_both_sides(c)`
> - `(a==b).subtract_from_both_sides(c)`
> - `(a==b).multiply_both_sides(c)`
> - `(a==b).divide_both_sides(c)`
> - `False` if `*/0`
> * `(a==b)^c` --> `a^c == b^c`
> * `f(a==b)` --> `f(a)==f(b)`
> relations:
> * `(a<b) +- c` same as:
> - `(a<b).add_to_both_sides(c)`
> - `(a<b).subtract_from_both_sides(c)`
> * `(a<b) */ c` same as:
> - `a*/c > b*/c` for `c` real and negative, or if `c` is assumed
> negative
> - `a*/c < b*/c` for `c` real and positive, or if `c` is assumed
> positive
> - `False` if `c=0` or assumed zero
> - if `c` contains variables (and no assumptions exist about it) raise
> `ArithmeticError: missing assumption: is ...>0?`
> - if `c` contains no variables `ArithmeticError: multiplication of
> inequality with irreal`
> * `(a<b)^c` --> `(a<b)^c`
> * `f(a<b)` --> `f(a<b)`
>
> Original description:
>
> From the following sage-devel thread:
>
> http://groups.google.com/group/sage-devel/t/951d510c814f894f
>
>
> Arithmetic with inequalities can be confusing, since Sage does nothing to
> keep the inequality ``correct``. For example:
>
> {{{
> On Thu, 10 Dec 2009 00:37:10 -0800 (PST)
> "[email protected]" <[email protected]> wrote:
>
> > sage: f = x + 3 < y - 2
> > sage: f*(-1)
> > -x - 3 < -y + 2
> }}}
>
> It seems MMA doesn't apply any automatic simplification in this
> case:
>
> {{{
> On Thu, 10 Dec 2009 09:54:36 -0800
> William Stein <[email protected]> wrote:
>
> > Mathematica does something weird and formal:
> >
> > In[1]:= f := x+3 < y-2;
> > In[3]:= f*(-1)
> > Out[3]= -(3 + x < -2 + y)
> }}}
>
> Maple acts more intuitively, though the way ``formal products``
> are printed leaves something to be desired, IMHO:
>
> {{{
> On Thu, 10 Dec 2009 14:15:53 -0800
> William Stein <[email protected]> wrote:
>
> > Here is what Maple does:
> >
> > flat:release_notes wstein$ maple
> > |\^/| Maple 13 (APPLE UNIVERSAL OSX)
> > ._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo
> Maple
> > Inc. 2009 \ MAPLE / All rights reserved. Maple is a
> trademark of
> > <____ ____> Waterloo Maple Inc.
> > | Type ? for help.
> > > f := x < y;
> > f := x < y
> >
> > > f*(-3);
> > -3 y < -3 x
> >
> > > f*z;
> > *(x < y, z)
> >
> > > f*a;
> > *(x < y, a)
> }}}
>
> We should multiply both sides of the inequality only if the
> argument is a real number (as opposed to a symbol with real domain), and
> invert the relation when the argument is negative.
>
> Note that GiNaC leaves everything formal, like MMA, by default:
>
> {{{
> ginsh - GiNaC Interactive Shell (ginac V1.5.3)
> __, _______ Copyright (C) 1999-2009 Johannes Gutenberg
> University Mainz,
> (__) * | Germany. This is free software with ABSOLUTELY
> NO WARRANTY.
> ._) i N a C | You are welcome to redistribute it under certain
> conditions.
> <-------------' For details type `warranty;'.
>
> Type ?? for a list of help topics.
> > f= x < y;
> x<y
> > f*-1;
> -(x<y)
> > f*-5;
> -5*(x<y)
> > f*-z;
> -z*(x<y)
> > f*z;
> z*(x<y)
> }}}
New description:
Equations and relations should behave like this:
equations:
* `(a==b) +-*/ c` same as:
- `(a==b).add_to_both_sides(c)`
- `(a==b).subtract_from_both_sides(c)`
- `(a==b).multiply_both_sides(c)`
- `(a==b).divide_both_sides(c)`
- `False` if `*/0`
* `(a==b)^c` --> `a^c == b^c`
* `f(a==b)` --> `f(a)==f(b)`
relations:
* `(a<b) +- c` same as:
- `(a<b).add_to_both_sides(c)`
- `(a<b).subtract_from_both_sides(c)`
* `(a<b) */ c` same as:
- `a*/c > b*/c` for `c` real and negative, or if `c` is assumed
negative
- `a*/c < b*/c` for `c` real and positive, or if `c` is assumed
positive
- `False` if `c=0` or assumed zero
- if `c` contains variables (and no assumptions exist about it) raise
`ArithmeticError: missing assumption: is ...>0?`
- if `c` contains no variables `ArithmeticError: multiplication of
inequality with irreal`
* `(a<b)^c` --> `(a<b)^c`
* `f(a<b)` --> `f(a<b)`
Original description:
From the following sage-devel thread:
http://groups.google.com/group/sage-devel/t/951d510c814f894f
Arithmetic with inequalities can be confusing, since Sage does nothing to
keep the inequality ``correct``. For example:
{{{
On Thu, 10 Dec 2009 00:37:10 -0800 (PST)
"[email protected]" <[email protected]> wrote:
> sage: f = x + 3 < y - 2
> sage: f*(-1)
> -x - 3 < -y + 2
}}}
It seems MMA doesn't apply any automatic simplification in this case:
{{{
On Thu, 10 Dec 2009 09:54:36 -0800
William Stein <[email protected]> wrote:
> Mathematica does something weird and formal:
>
> In[1]:= f := x+3 < y-2;
> In[3]:= f*(-1)
> Out[3]= -(3 + x < -2 + y)
}}}
Maple acts more intuitively, though the way ``formal products`` are
printed leaves something to be desired, IMHO:
{{{
On Thu, 10 Dec 2009 14:15:53 -0800
William Stein <[email protected]> wrote:
> Here is what Maple does:
>
> flat:release_notes wstein$ maple
> |\^/| Maple 13 (APPLE UNIVERSAL OSX)
> ._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple
> Inc. 2009 \ MAPLE / All rights reserved. Maple is a trademark of
> <____ ____> Waterloo Maple Inc.
> | Type ? for help.
> > f := x < y;
> f := x < y
>
> > f*(-3);
> -3 y < -3 x
>
> > f*z;
> *(x < y, z)
>
> > f*a;
> *(x < y, a)
}}}
We should multiply both sides of the inequality only if the argument
is a real number (as opposed to a symbol with real domain), and invert the
relation when the argument is negative.
Note that GiNaC leaves everything formal, like MMA, by default:
{{{
ginsh - GiNaC Interactive Shell (ginac V1.5.3)
__, _______ Copyright (C) 1999-2009 Johannes Gutenberg University
Mainz,
(__) * | Germany. This is free software with ABSOLUTELY NO
WARRANTY.
._) i N a C | You are welcome to redistribute it under certain
conditions.
<-------------' For details type `warranty;'.
Type ?? for a list of help topics.
> f= x < y;
x<y
> f*-1;
-(x<y)
> f*-5;
-5*(x<y)
> f*-z;
-z*(x<y)
> f*z;
z*(x<y)
}}}
--
--
Ticket URL: <http://trac.sagemath.org/ticket/7660#comment:46>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.