Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doctest for: Positive raised by a positive power is not known to be real #21940

Closed
pelegm opened this issue Nov 23, 2016 · 21 comments
Closed

Doctest for: Positive raised by a positive power is not known to be real #21940

pelegm opened this issue Nov 23, 2016 · 21 comments

Comments

@pelegm
Copy link
Contributor

pelegm commented Nov 23, 2016

But it is known to be positive...

See the following code:

sage: assume(x>0)
sage: x.is_real()
True
sage: x.is_positive()
True
sage: (x**x).is_positive()
True
sage: (x**x).is_real()
False

For comparison, this is how SymPy handles this:

In [2]: x = Symbol('x', positive=True)

In [3]: x.is_positive
Out[3]: True

In [4]: x.is_real
Out[4]: True

In [5]: (x**x).is_positive
Out[5]: True

In [6]: (x**x).is_real
Out[6]: True

Depends on #21963

CC: @rwst

Component: symbolics

Keywords: is_real, days79

Author: Peleg Michaeli, Ralf Stephan

Branch/Commit: c883299

Reviewer: Ralf Stephan, Peleg Michaeli

Issue created by migration from https://trac.sagemath.org/ticket/21940

@pelegm pelegm added this to the sage-7.5 milestone Nov 23, 2016
@rwst
Copy link

rwst commented Nov 23, 2016

comment:3

What Sage version is this? With Sage-7.5beta3 I get:

sage: assume(x>0)
sage: x.is_real()
True
sage: (x*x).is_real()
True

@pelegm
Copy link
Contributor Author

pelegm commented Nov 25, 2016

comment:4

Replying to @rwst:

What Sage version is this? With Sage-7.5beta3 I get:

sage: assume(x>0)
sage: x.is_real()
True
sage: (x*x).is_real()
True

Hi,

This was tested on 7.5beta3. You've checked x*x, and I have checked x**x.

@rwst
Copy link

rwst commented Nov 25, 2016

comment:5

Fixed in pynac git master, see pynac/pynac@e5c6cd2

Please add a doctest to Expression.is_real() in symbolic/expression.pyx

@rwst
Copy link

rwst commented Nov 25, 2016

Dependencies: pynac-0.7.2

@pelegm
Copy link
Contributor Author

pelegm commented Nov 25, 2016

Commit: 65e6c10

@pelegm
Copy link
Contributor Author

pelegm commented Nov 25, 2016

New commits:

65e6c10positive ** positive = real (doctest only) #21940

@pelegm
Copy link
Contributor Author

pelegm commented Nov 25, 2016

Branch: u/pelegm/21940

@pelegm
Copy link
Contributor Author

pelegm commented Nov 25, 2016

Author: Peleg Michaeli

@rwst
Copy link

rwst commented Dec 6, 2016

comment:7

Maybe interesting in this regard that fixing this allows Sage to simplify some apparently complex expressions, e.g.

Before:
sqrt(abs(1/25*(3*(2*sqrt(3)*sqrt(2) - 3)*(sqrt(6) - 2) + 16*sqrt(3)*sqrt(2) +
5*sqrt(6) - 54)^2 + 1/25*(3*(sqrt(6) - 2)*(sqrt(6) - 4) + 14*sqrt(3)*sqrt(2) +
4*sqrt(6) - 42)^2 + 144/25*(sqrt(3)*sqrt(2) - sqrt(6))^2))

After:
sqrt(1/25*(3*(2*sqrt(3)*sqrt(2) - 3)*(sqrt(6) - 2) + 16*sqrt(3)*sqrt(2) +
5*sqrt(6) - 54)^2 + 1/25*(3*(sqrt(6) - 2)*(sqrt(6) - 4) + 14*sqrt(3)*sqrt(2) +
4*sqrt(6) - 42)^2 + 144/25*(sqrt(3)*sqrt(2) - sqrt(6))^2)

(from a doctest in matrix_symbolic_dense.pyx)

@pelegm

This comment has been minimized.

@pelegm
Copy link
Contributor Author

pelegm commented Dec 6, 2016

comment:9

Is this solving the case

sage: assume(x, 'real')
sage: (2**x).is_positive()
True
sage: (2**x).is_real()
False

as well?

@rwst
Copy link

rwst commented Dec 6, 2016

comment:10

Right, now that works too.

@rwst
Copy link

rwst commented Dec 6, 2016

Changed dependencies from pynac-0.7.2 to #21963

@rwst
Copy link

rwst commented Dec 20, 2016

Changed branch from u/pelegm/21940 to u/rws/21940

@rwst
Copy link

rwst commented Dec 20, 2016

Changed author from Peleg Michaeli to Peleg Michaeli, Ralf Stephan

@rwst
Copy link

rwst commented Dec 20, 2016

Changed commit from 65e6c10 to c883299

@rwst
Copy link

rwst commented Dec 20, 2016

Reviewer: Ralf Stephan

@rwst
Copy link

rwst commented Dec 20, 2016

comment:12

Replying to @pelegm:

Is this solving the case

sage: assume(x, 'real')
sage: (2**x).is_positive()
True
sage: (2**x).is_real()
False

as well?

I added this as doctest. Could you review it please?


New commits:

23c987eMerge branch 'develop' into t/21940/21940
c88329921940: add one doctest

@rwst rwst changed the title Positive raised by a positive power is not known to be real Doctest for: Positive raised by a positive power is not known to be real Dec 20, 2016
@pelegm
Copy link
Contributor Author

pelegm commented Mar 12, 2017

Changed reviewer from Ralf Stephan to Ralf Stephan, Peleg Michaeli

@pelegm
Copy link
Contributor Author

pelegm commented Mar 12, 2017

comment:13

Looks great.

@vbraun
Copy link
Member

vbraun commented Mar 27, 2017

Changed branch from u/rws/21940 to c883299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants