Opened 5 years ago

Closed 4 years ago

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

Reported by: Owned by: pelegm major sage-7.5 symbolics is_real, days79 rws Peleg Michaeli, Ralf Stephan Ralf Stephan, Peleg Michaeli N/A c883299 c88329909934b9561314344347a7bd7c3c0ec755 #21963

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
```

### comment:2 Changed 5 years ago by pelegm

• Cc rws added; rsw removed

### comment:3 follow-up: ↓ 4 Changed 5 years ago by rws

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
```

### comment:4 in reply to: ↑ 3 Changed 5 years ago by pelegm

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`.

### comment:5 Changed 5 years ago by rws

• Dependencies set to pynac-0.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 pelegm

• Authors set to Peleg Michaeli
• Branch set to u/pelegm/21940
• Status changed from new to needs_review

New commits:

 ​65e6c10 `positive ** positive = real (doctest only) #21940`

### comment:7 Changed 5 years ago by rws

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 pelegm

• Description modified (diff)

### comment:9 follow-up: ↓ 12 Changed 5 years ago by pelegm

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 rws

• Dependencies changed from pynac-0.7.2 to #21963

Right, now that works too.

### comment:11 Changed 5 years ago by rws

• Branch changed from u/pelegm/21940 to u/rws/21940

### comment:12 in reply to: ↑ 9 Changed 5 years ago by rws

• Authors changed from Peleg Michaeli to Peleg Michaeli, Ralf Stephan
• 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

Is this solving the case

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

as well?

New commits:

 ​23c987e `Merge branch 'develop' into t/21940/21940` ​c883299 `21940: add one doctest`

### comment:13 Changed 4 years ago by pelegm

• 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 vbraun

• Branch changed from u/rws/21940 to c88329909934b9561314344347a7bd7c3c0ec755
• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.