3 | | Currently, `I` is defined in `sage/symbolic/pynac.pyx` within the function `init_pynac_I`. |
| 3 | **Why?** To allow it to be used in combination with elements of QQbar, CC, etc., without coercion forcing the expression to SR. For example, `1.0 + I` is now an element of CC instead of SR. |
| 4 | |
| 5 | **How?** We set `I` in sage.all to the generator of ℚ[i], and deprecate importing it from `sage.symbolic.I`. The symbolic `I` remains available from `sage.symbolic.constants` for library code working with symbolic expressions, and as `SR(I)` or `SR.I()`. We create a dedicated subclass of quadratic number field elements to make it possible to support features similar to those of symbolic expressions of the form `a + I*b` that would not make sense for number field elements (or be too hard to implement, or pollute the namespace). |
| 6 | |
| 7 | **Why not ℤ[i]?** Because the class hierarchy of number field and order elements makes it difficult to provide the compatibility features mentioned above for elements of both ℤ[i] and ℚ[i]. Having `I` be an element of ℚ[i] covers almost all use cases (all except working with algebraic integers?), and people who work with orders are sophisticated enough to explicitly ask for I ∈ ℤ[i] when they need that. (This is a debatable choice. We could probably do without the dedicated subclass for elements of ℚ[i], at the price of breaking backward compatibility a bit more.) |