On Sun, 13 May 2012 14:13:46 -0700 (PDT)
mmarco <[email protected]> wrote:

> My problem was that i needed to do implicit derivation. Something
> like:
> 
> sage: f=3*x^2*y^3-5*x*y+x^2-3*y^2+4*x-3*y+1
> sage: f.diff(x)
> 9*x^2*y(x)^2*D[0](y)(x) + 6*x*y(x)^3 - 5*x*D[0](y)(x) - 6*y(x)*D[0](y)
> (x) + 2*x - 5*y(x) - 3*D[0](y)(x) + 4
> 
> 
> and then substitute the value of x, y(x) (which in general will be an
> algebraic number) and solve for D[0](y)(x). I know that the first
> derivative is just minus the quotient of the partial derivatives of f,
> but i would need also the higher order derivatives, which forces me to
> repeat the previous process several times.
> 
> In fact i finally found a solution the implicit derivation (see ticket
> 12922), but since i run into this issue of not being able to work with
> algebraic numbers in the symbolic ring, i thought it would be a nice
> feature to have.
> 
> My solution is to convert these numbers into symbolic variables before
> feeding them to the symbolic ring, and then converting back these
> variables into their value when i get them back in my polynomial ring.
> But that sounds like a dirty hack.

In sage/symbolic/ring.pyx, lines 167-175 have the following code:

            if ComplexField(mpfr_prec_min()).has_coerce_map_from(R):
                # Anything with a coercion into any precision of CC

                # In order to have coercion from SR to AA or QQbar,
                # we disable coercion in the reverse direction.
                # This makes the following work:
                # sage: QQbar(sqrt(2)) + sqrt(3)
                # 3.146264369941973?
                return R not in (RLF, CLF, AA, QQbar)


Modifying this should allow you to use algebraic numbers in symbolic
expressions. IIRC, this is left from the days when we thought having
coercions in both directions is not acceptable. I don't think
changing it will cause any problem apart from a few broken doctests.


Cheers,
Burcin

-- 
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to