Opened 5 years ago
Closed 4 years ago
#21940 closed defect (fixed)
Doctest for: Positive raised by a positive power is not known to be real
Reported by:  pelegm  Owned by:  

Priority:  major  Milestone:  sage7.5 
Component:  symbolics  Keywords:  is_real, days79 
Cc:  rws  Merged in:  
Authors:  Peleg Michaeli, Ralf Stephan  Reviewers:  Ralf Stephan, Peleg Michaeli 
Report Upstream:  N/A  Work issues:  
Branch:  c883299 (Commits, GitHub, GitLab)  Commit:  c88329909934b9561314344347a7bd7c3c0ec755 
Dependencies:  #21963  Stopgaps: 
Description (last modified by )
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
Change History (14)
comment:1 Changed 5 years ago by
 Cc rsw added
comment:2 Changed 5 years ago by
 Cc rws added; rsw removed
comment:3 followup: ↓ 4 Changed 5 years ago by
comment:4 in reply to: ↑ 3 Changed 5 years ago by
Replying to rws:
What Sage version is this? With Sage7.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
.
comment:5 Changed 5 years ago by
 Dependencies set to pynac0.7.2
Fixed in pynac git master, see https://github.com/pynac/pynac/commit/e5c6cd261e2652b7c4e7b4ca5f1bac9565ab0ef8
Please add a doctest to Expression.is_real()
in symbolic/expression.pyx
comment:6 Changed 5 years ago by
 Branch set to u/pelegm/21940
 Commit set to 65e6c10c2da5e4d20bbc6f7f225ade3f4778fc0c
 Status changed from new to needs_review
New commits:
65e6c10  positive ** positive = real (doctest only) #21940

comment:7 Changed 5 years ago by
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
)
comment:8 Changed 5 years ago by
 Description modified (diff)
comment:9 followup: ↓ 12 Changed 5 years ago by
Is this solving the case
sage: assume(x, 'real') sage: (2**x).is_positive() True sage: (2**x).is_real() False
as well?
comment:10 Changed 5 years ago by
 Dependencies changed from pynac0.7.2 to #21963
Right, now that works too.
comment:11 Changed 5 years ago by
 Branch changed from u/pelegm/21940 to u/rws/21940
comment:12 in reply to: ↑ 9 Changed 5 years ago by
 Commit changed from 65e6c10c2da5e4d20bbc6f7f225ade3f4778fc0c to c88329909934b9561314344347a7bd7c3c0ec755
 Reviewers set to Ralf Stephan
 Summary changed from Positive raised by a positive power is not known to be real to Doctest for: Positive raised by a positive power is not known to be real
comment:13 Changed 4 years ago by
 Reviewers changed from Ralf Stephan to Ralf Stephan, Peleg Michaeli
 Status changed from needs_review to positive_review
Looks great.
comment:14 Changed 4 years ago by
 Branch changed from u/rws/21940 to c88329909934b9561314344347a7bd7c3c0ec755
 Resolution set to fixed
 Status changed from positive_review to closed
What Sage version is this? With Sage7.5beta3 I get: