Opened 11 years ago

Closed 6 years ago

# qqbar and SR

Reported by: Owned by: jason AlexGhitza major sage-duplicate/invalid/wontfix coercion cwitty Marc Mezzarobba N/A

It would be nice if roots of quadratics printed using the quadratic formula in QQbar, i.e.,

```sage: QQbar(sqrt(2))
sqrt(2)
```

Additionally, it would be nice if we could wrap qqbar elements as SR objects.

The first patch just affects printing of qqbar elements. The second lets you do more than just print (e.g., SR(QQbar(sqrt(2))) should give you sqrt(2), not just print sqrt(2))

### comment:1 Changed 11 years ago by jason

This patch almost certainly needs work, but does give some nice results:

```sage: QQbar(sqrt(5))
sqrt(20)/2
sage: QQbar(sqrt(2))
sqrt(8)/2
```

Things are not simplified because I don't want to do any extra work in the printing.

### comment:2 Changed 11 years ago by jason

Another example with this patch:

```sage: m=matrix(2,2,[0,1,1,1]);m
[0 1]
[1 1]
sage: m.eigenvalues()
[(--1-sqrt(5))/2, (--1+sqrt(5))/2]

```

### comment:3 Changed 11 years ago by jason

That last patch corrects the double negative, so I get:

```sage: m=matrix(2,2,[0,1,1,1]);m
[0 1]
[1 1]
sage: m.eigenvalues()
[(1-sqrt(5))/2, (1+sqrt(5))/2]

```

### Changed 11 years ago by jason

apply on top of previous patch

### comment:4 Changed 11 years ago by jason

I've attached a work-in-progress patch that allows qqbar elements to be converted to symbolics elements in a smart way, i.e., square roots become symbolic square roots, etc.

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

• Status changed from new to needs_work

### comment:6 Changed 11 years ago by jason

• Priority changed from minor to major

Here is another problem that could probably be solved if qqbar elements could be converted to symbolics. The application for this example was trying to plot a line from the eigenvector of a matrix:

```sage: A=matrix(QQ,2,2,[2,5,1,2])
sage: EV=A.right_eigenvectors()
sage: EV
[(-0.2360679774997897?, [(1, -0.4472135954999580?)], 1), (4.236067977499789?, [(1, 0.4472135954999580?)], 1)]
sage: evec=EV[0][1][0]
sage: var('t')
t
sage: evec.n()*t # works fine
(t, -0.447213595499958*t)
sage: t*evec
Traceback (most recent call last):
...
NotImplementedError: symbol

```

### comment:7 Changed 11 years ago by jason

• Component changed from algebra to coercion
• Description modified (diff)
• Summary changed from qqbar quadratic elements to qqbar and SR

### comment:8 Changed 11 years ago by jason

• Description modified (diff)

### comment:9 Changed 8 years ago by jdemeyer

• Milestone changed from sage-5.11 to sage-5.12

Related: #14239

### comment:11 Changed 7 years ago by vbraun_spam

• Milestone changed from sage-6.1 to sage-6.2

### comment:12 Changed 7 years ago by vbraun_spam

• Milestone changed from sage-6.2 to sage-6.3

### comment:13 Changed 7 years ago by vbraun_spam

• Milestone changed from sage-6.3 to sage-6.4

### comment:14 Changed 6 years ago by jdemeyer

• Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
• Reviewers set to Marc Mezzarobba
• Status changed from needs_work to positive_review

Duplicate of #14239

### comment:15 Changed 6 years ago by vbraun

• Resolution set to duplicate
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.