Ticket #8626 (needs_work defect)
qqbar and SR
| Reported by: | jason | Owned by: | AlexGhitza |
|---|---|---|---|
| Priority: | major | Milestone: | sage-5.10 |
| Component: | coercion | Keywords: | |
| Cc: | cwitty | Work issues: | |
| Report Upstream: | N/A | Reviewers: | |
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description (last modified by jason) (diff)
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))
Attachments
Change History
comment:2 Changed 3 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 3 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 3 years ago by jason
-
attachment
trac-8626-qqbar-symbolics.patch
added
apply on top of previous patch
comment:4 Changed 3 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:6 Changed 3 years ago by jason
- Cc cwitty added
- 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

This patch almost certainly needs work, but does give some nice results:
Things are not simplified because I don't want to do any extra work in the printing.