Repository: LMFDB/lmfdb

Issue:
Some elliptic curves over number fields have incorrect "Q-curve" flag
This is more of a data issue not a code issue.  At some point I realised that my Q-curve test was wrong (it gives false negatives, never false positives) and pending a correction to that code stopped computing that flag.  Two problems with this:  (1) curves whose Q-curve status is unknown ended up with False in the database; (2) curves whose Q-curve status was incorrectly computed never had the flag corrected.

Extent of the problem:  fields of degrees 2, 3, 4.  I think I stopped computing the Q-curve status during the degree 4 curve computations.

Solution:  first, to avoid any wrong data being present, I suggest that I will change all 'q_curve'=False to 'q_curve'='?' or similar.  This will be very quick, and some people will object since it will include curves which cannot be Q-curves for easy reasons.
Second, recompute or compute the Q-curve status of all curves.  This will take a while.  I'll start with quadratic fields which are easier;   a general algorithm which works even over non-Galois fields has not been implemented by anoone (to my knowledge) and I am working on it.  The point is that the definition of Q-curve is that E should be isogenous to all its Galois conjugates over Q-bar, and it is __not__ enough to check the curves isogenous to E over its field of definition (which we already have in the database, of course).


Discussion:
I'm now ready to start a script which will go through all the nfcurves collection, insert the correct Q-curves flag for curves defined over quadratic fields, and replace False by '?' in higher degree.  This might take 10 hours (rough estimate).  I think this worth doing now since it will replace quite a lot of incorrect data even though it is not complete, since an implementation in higher degree will take longer.
Example: there are 74037 curves in the database over 2.0.4.1, of which 2476 (about 3.3%) will have their Q-curve status corrected from False to True.  This includes some really stupid cases where the j-invariant is in Q.
The rewrite is under way, after which (and after the new collection has replaced the current one both on beta and on the cloud)  (1) all quadratic fields should have the flag set and correctly; (2) over higher degree fields there will be more True than before since I am making sure that all curves with j-invariant in Q or with CM are set to True (this is quick as it can be determined from the data stored, with no computation); (3) there will be none set to  False over fields of degree >2, instead they will be set to '?'.

While that is running I will make sure that the code handles the '?' value correctly, so there will be a pull request associated with this after all.

Resolving patch:
diff --git a/lmfdb/ecnf/WebEllipticCurve.py b/lmfdb/ecnf/WebEllipticCurve.py
--- a/lmfdb/ecnf/WebEllipticCurve.py
+++ b/lmfdb/ecnf/WebEllipticCurve.py
@@ -408,12 +408,15 @@ def make_E(self):
             self.ST = st_link_by_name(1,2,'SU(2)')
 
         # Q-curve / Base change
-        self.qc = "no"
-        try:
-            if self.q_curve:
-                self.qc = "yes"
-        except AttributeError:  # in case the db entry does not have this field set
-            pass
+        self.qc = self.q_curve
+        if self.qc == "?":
+            self.qc = "not determined"
+        elif self.qc == True:
+            self.qc = "yes"
+        elif self.qc == False:
+            self.qc = "no"
+        else: # just in case
+            self.qc = "not determined"
 
         # Torsion
         self.ntors = web_latex(self.torsion_order)
@@ -544,7 +547,8 @@ def make_E(self):
             self.properties += [('base-change', 'yes: %s' % ','.join([str(lab) for lab in self.base_change]))]
         else:
             self.base_change = []  # in case it was False instead of []
-            self.properties += [('Q-curve', self.qc)]
+            self.properties += [('base-change', 'no')]
+        self.properties += [('Q-curve', self.qc)]
 
         r = self.rk
         if r == "?":


Test patch: