-
-
Notifications
You must be signed in to change notification settings - Fork 541
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
symbolic radical expression for algebraic number #14239
Comments
Attachment: trac_14239_algebraic_to_radicals.patch.gz |
comment:1
I wrapped my code into two methods Only second degree polynomials supported so far. I guess this should cover the most useful use cases: third and fourth degree are certainly possible, but don't help very much with the readability of the result in most cases. Square roots, on the other hand, are everywhere, so being able to represent these is a huge win imho. The code I wrote does rely little on the internal workings of algebraic numbers and their descriptions, mostly because I haven't dug into that code yet. I guess the check which solution of the quadratic equation to choose might benefit from a more direct comparison of separating intervals, but at the moment I see no urgent performance issue with most use cases of this function. |
Reviewer: Marc Mezzarobba |
comment:3
I think the feature you are looking for sort of exists. But it is available for elements of number fields, not algebraic numbers. And it is pretty inconvenient to use with algebraic numbers because Yet, with the example from your question on AskSage, one can do:
So I disagree with the approach you take in your patch: IMO, we should make something like the above example work automatically and share the actual conversion code between algebraic numbers and number fields instead of implementing essentially the same feature twice. [edit: add missing word] |
comment:5
Replying to @mezzarobba:
I just gave that code a try, and on sage 5.12 it failed in the assignment of
Probably due to an outdated sage, so feel free to ignore this if that's the case. Can't update this system just now. |
comment:6
Replying to @gagern:
Yes, I think so. (I tried again on |
Branch: u/gagern/ticket/14239 |
Commit: |
New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:11
I notice that in real world applications, the check for
It gets stuck in several layers of
On the one hand, I wonder whether there is some better way to detect an inexact conversion. I haven't looked enough at the internal structure of a symbolic expression to know how to handle this. On the other hand, I wonder why this comparison is taking so long. Or even whether it is simply taking excessively long, or perhaps even got stuck completely. Perhaps this is an indication of some more fundamental problem. If you want to invastigate this, you can do so without checking out this branch. Simply using the example above, the relevant operation is the following:
Even as it stands, having the Barring any good ideas, I might eventually end up adding an optional argument |
comment:12
The problem is, an expression like this:
has (at least) 3 possible values. You need to specify branch cuts to single out a particular value in, say, CC. Algebraically,
which is of rather high degree. The other elements you add to this will just add to the degree, since the next time a While in the expression for
and then construct b from that, you should already get a little faster results. The problems you are running into are fairly well-understood and real. Symbolic notation as you use it fails to express the full algebraic relations once you start repeating related expressions. EDIT: apologies. The fact that the value didn't match was due to a missubstitution on my part. I've corrected the result below. The value
The fundamental problem remains, though: the symbolic version doesn't quite carry the same information. In addition, some of the slowness might be due to ``QQbar` itself, since:
so QQbar is slow exactifying an element Computer algebra systems such as maple have their own symbolic ways of dealing with the ambiguity introduced by defining elements as "roots" of polynomials:
which allows it to simplify |
comment:13
Thanks for explaining a bit of what's going on here to cause such delays. Alternate ways to compute things more efficiently are all very well, but won't be of use unless I can make this automatic somehow. After all, on the high level all I do is compare two numbers, without wanting to think about implementation details. While investigating this problem, I noticed that for my original length expression Let me try to think this through. Naively I'd rewrite
Does this approach make sense? |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. This was a forced push. Last 10 new commits:
|
comment:98
Passes |
comment:99
What is the point of
I really do not like the attribute symbolic. Why this result needs to be cached? You can possibly cache in the parent a symbolic version of the generator. The fact that |
comment:100
What is the point of looking for an approximation
|
comment:101
Instead of |
Changed author from Martin von Gagern to Martin von Gagern, Jeroen Demeyer |
comment:102
Replying to @videlec:
That one is from 4626286 by Jeroen, but you have the patch reversed. I assume that
Could it be you are seeing the wrong patch direction here as well? We are dropping the
Yes, you are definitely seeing the patch in the wrong direction. A good thing that you pasted the patch lines above, otherwise I would have ben thoroughly confused. Replying to @videlec:
I must confess that I was a bit unhappy with that myself when I read it. But the code just changed place and location, it wasn't really changed. And I figure that if you ever have a cyclotomic field of such a great order that you are affected by rounding errors here, its dimension would be high enough that you'd not get any real work done with it in any case. So I decided not to complain or modify this, since it's not directly related to the issue at hand and I feard that discussing one more item might prevent stuff from getting accepted. Are you sure you want this handled with this ticket here? If so I'll have to work out how to find the right Replying to @videlec:
Thanks, that should be a quick and obvious improvement. Will push a commit to that effect once I know whether to address the approximation issue above as well. |
comment:103
Replying to @gagern:
Oups... sorry
It should be easy, Vincent |
comment:104
Replying to @videlec:
Yes, using |
comment:105
Replying to @videlec:
That won't work: at that point (since the So I'm back to asking for review, even though I changed nothing. |
comment:106
Replying to @gagern:
That's good to me! Vincent |
Changed reviewer from Marc Mezzarobba, Jeroen Demeyer to Marc Mezzarobba, Jeroen Demeyer, Vincent Delecroix |
Changed branch from u/gagern/ticket/14239 to |
It would be nice to have a function which converts algebraic numbers to symbolic expressions using radicals, at least for those cases where this is possible (i.e. the cases where the minimal polynomial of the algebraic number has a degree less than 5). For the quadratic case, I have a code snippet to illustrate what I'm asking for:
These functions could then be applied to vectors or matrices over algebraic real or complex numbers in order to obtain an exact description of the relevant values using radicals.
This request is a spin-off from my question on Ask Sage.
Follow-up tickets: #17516, #17517
Depends on #17495
Depends on #16964
Component: number fields
Author: Martin von Gagern, Jeroen Demeyer
Branch/Commit:
4626286
Reviewer: Marc Mezzarobba, Jeroen Demeyer, Vincent Delecroix
Issue created by migration from https://trac.sagemath.org/ticket/14239
The text was updated successfully, but these errors were encountered: