On Wed, Mar 12, 2014 at 06:41:07AM -0700, Eric Gourgoulhon wrote:
> In order to treat tensor fields on a parallelizable domain N of some
> smooth manifold as elements of a free module (cf. #15916 and this post),
> one has first to introduce the commutative ring C^oo(N) of smooth
> functions N --> R, as a new class, ScalarFieldRing say. Browsing through
> Sage reference manual, a natural guess would be to make it a subclass of
You don't necessarily need too. You could also just inherit from
Parent; the important thing is to set the category to
CommutativeRing is a bit of a legacy stuff: it's still there because
some features have not yet been moved to categories, and also because
some parents where pure arithmetic speed on elements is vital
(e.g. small finite fields), need it to by Cython.
The issue here is that CommutativeRing.__init__ requires the argument "base_ring" and in the present context, I don't know what to put here: the ring C^oo(N) does not depend upon any other ring. Shall I put self, i.e. write CommutativeRing.__init__(self, self) ?
- create RSF (for "real symbolic field") to isolate pi and sqrt(2) from
cos(x) in the symbolic ring.
- re-create RR as an "overlay field" over the different representations
This is not about floating-point arithmetic nor evaluation, but about a
common parent with some semantics in it.
I would advocate that RLF is a very good approximation of what should
be RR. Perhaps one good direction to take is to try to make RLF
smarter and contains all constants from pi to cos(42^e).
This is half good, I am happy that RLF wraps symbolic constants. But,
first of all there can not be any reasonable coercion from SR to RLF
as SR is much bigger. Secondly, SR is not consistent with evaluation
Real Field with 53 bits of precision
I would prefer the second parent to be something like
RealSymbolicField or RealNumbers or whatever but not symbolic ring.
Thirdly, I would like to be able to compare real numbers built from
different sources :
- algebraic numbers (built from QQbar and NumberField)
- symbolic constants
- continued fractions
- binary expansions
sage: R.<X> = QQ
sage: K.<a> = NumberField(X^4 - 5*X^2 + 5, embedding=1.17)
sage: expr = 2 * cos(3*pi/10)
sage: RLF(a) == RLF(expr) # does not work in RLF
sage: bool(SR(a) == SR(expr)) # does not work in SR
Even if they are equal as real numbers. So what is broken : comparison
in SR? comparison in RLF?
Any number cos(rational x pi) is algebraic and equality of algebraic
numbers is decidable. Moreover, it is not because something is
undecidable that Sage should return a wrong answer. In that case, it
would be good to have a third party in comparison (either returning
Unknown or raising exception).