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
Faster exactification using numeric minpoly #16222
Comments
Branch: u/gagern/ticket/16222 |
comment:2
These modifications are not ready for inclusion yet, they need some discussion first.
New commits:
|
Commit: |
comment:4
Rebased to current develop, and changed test case to avoid dependency on #14239. I'm now requesting review since that's what I need even if I consider it likely that the reviewer will not agree with all the choices I made as outlined above. |
comment:6
Hello, Did you try using the magic
The advantage is that it would potentially speed up non symbolic cases. Vincent |
comment:7
Replying to @videlec:
My code builds on that, since expression.minpoly calls calculus.minpoly which in turn calls algdep. But it does come with a verification step, ensuring that the found polynomial is in fact the one we need. I'm not sure I'd trust the output from
Well, one alternative would be to directly feed the descriptor DAG into |
comment:8
Replying to @gagern:
Of course we can not believe the output of
Right, checking that it is actually an annihilator polynomial is harder... I do not see anything different from calling |
comment:9
Replying to @videlec:
I'm unsure about the relation between “candidate” and “reliable”. The former implies something that needs to be verified, the latter like I could rely on it without verification. But I guess what you mean is that we could construct a candidate which would very likely be the correct one. But “very likely” isn't enough in my opinion.
In theory, we could go the reverse route: take the descriptor dag and try building a symbolic expression from this which in turn can be fed to Maxima for verification. But I'm far from certain that this is a good idea for those cases which didn't originate in a symbolic expression in the first place. Which brings us back to the request as it currently stands, right? |
comment:10
I just notice that your ticket is based on a very old version of Sage (6.3.beta5)... it would be nice to upgrade to the current 6.5.rc0. More about the ticket, I am worried because
|
comment:11
Replying to @videlec:
So what do you propose? That we always try to build a symbolic expression from the descriptor dag? |
comment:12
Replying to @gagern:
No. But at least when performing arithmetic operations on |
comment:14
I find that it's hard to draw the line. Your example of And I'm using it unconditionally, which leads to a lot of doctests failing. Some of them for better:
But some of them for worse:
I don't have any performance comparisons yet, but I guess that there might well be cases where the current approach was fast enough, but the whole detour via symbolic expressions, PARI's algdep and Maxima for verification might have a severe impact. So my key concern right now is, when do we want to use this approach, and when not to? If multithreading in Python were a more natural concept, I'd be so bold as to suggest that we start both approaches, and the one which terminates first wins, aborting the other. This might make results somewhat unpredictable, though. And given the state of threading support in CPython, I doubt this is realistic in any case. Here are a few more realistic ways how we could make that case distinctions in a way that might make sense. I'm not completely happy with any of them.
|
comment:15
Replying to @gagern:
Not really for worse. The previous doctests assumed that at some point in the code EDIT: I removed the non-example I previously wrote here.
Option 3 is definitely needed. I am against option 1 as we do not want to keep the origin of the objects. By the way, do you have an idea to have quick symbolic representation for
I.e. roots of For options 2 and 4 there is a right balance to find. |
comment:16
Not exactly related to this ticket: I just found out some maxima magic to get the polynomial of symbolic expressions involving square root and such (p. 1041 of the maxima manual):
It is way much much faster than what we have in Sage for minpoly:
|
comment:17
Replying to @videlec:
Nice! Do you want to open a spin-off ticket, asking for a way to exploit this functionality in Sage? As you said, it's not exactly on topic here, but it would be a shame if that idea got lost once we have this issue here wrapped up. |
comment:18
Replying to @videlec:
I guess once we have a method which can be called by hand, we can use that to experiment a bit, in our daily work, and can ask others to do the same. That might give us some intuition about when to use which. So I'd keep this out of this ticket for now, and instead post a follow-up ticket to investigate that. |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:20
Rebased to 6.6.rc2 and added public interface I considered “numeric” instead of “symbolic”, but I at least tend to associate “numeric” with “inexact”, so I felt that term might be more confusing. Also considered “algoiritm='symbolic'” but I think in the long run we might have various alternatives which could be tried one after the other, so a flag to enable or disable each sounds more useful. The same holds for a new method as opposed to an argument to Now that my new code is not called by default, it shouldn't have any adverse effects on other parts of the code, which might make this easier to review. I hope this can be merged, to enable some evaluation in preparation for #18122 which I filed for automatically choosing between algorithms. I fear that might be hard to get right. |
comment:21
Hello, It's a pity that we got
I added a new commit to handle that. On the other hand, did you know that the symbolic ring is very broken to deal with n-th root
As Vincent New commits:
|
Changed branch from u/gagern/ticket/16222 to u/vdelecroix/16222 |
Reviewer: Vincent Delecroix |
comment:24
Replying to @videlec: No, since in general they are not what I'd consider fast. To obtain an exact symbolic number using #14239, we need to have a minimal polynomial, while this one here is aiming to obtain that polynomial more quickly. #17516 would extend #14239 to give results in a larger number of cases, but won't affect this here either. If at all, there is some overlap with #17886, since if that works out relly well, it might make this one here superfluous. I don't think so, though, and since we are only offering this here as an alternative for now, we can use #18122 to evaluate those alternatives once we get there.
No, I did not, but I share your deep concerns. Have you filed a ticket for this yet? |
Dependencies: #15605 |
This is a spinoff from #14239 comment:13. There I noticed that for a large symbolic expressions
b
, the callb.minpoly()
was a lot (by several orders of magnitude) faster than the callQQbar(b).minpoly()
. We should try to make this speed gain available to those algebraic numbers which were constructed from symbolic expressions.I now know that the speed gain is almost certainly due to the numeric algorithm in
calculus.minpoly
. So what we should in my opinion do is use that numeric algorithm to obtain a minimal polynomial of the whole expression, and if that succeeds, base subsequent exactifications on that polynomial instead of the nested tree of algebraic number descriptors.Depends on #15605
Component: number fields
Author: Martin von Gagern
Branch/Commit: u/vdelecroix/16222 @
8773468
Reviewer: Vincent Delecroix
Issue created by migration from https://trac.sagemath.org/ticket/16222
The text was updated successfully, but these errors were encountered: