Opened 4 years ago

Last modified 4 years ago

#24334 new defect

sympy symbol -> SR drops assumptions

Reported by: jdemeyer Owned by:
Priority: major Milestone: sage-8.2
Component: symbolics Keywords:
Cc: rws Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #24067 Stopgaps:

Status badges

Description (last modified by jdemeyer)

It is possible to add assumptions on sympy symbols:

sage: from sympy import Symbol
sage: n = Symbol("n", integer=True)

However, these are lost when converting to SR:

def _sympysage_symbol(self):

        sage: from sympy import Symbol
        sage: assert x._sympy_() == Symbol('x')
        sage: assert x == Symbol('x')._sage_()
    from sage.symbolic.ring import SR
    return SR.var(

This is the indirect cause for the different results below (based on a doctest in src/sage/tests/french_book/

sage: from sympy import Symbol, rsolve_hyper
sage: n = Symbol("n", integer=True)
sage: rsolve_hyper([-2,1], 2^(n+2), n)
2**n*C0 + 2**(n + 2)*(C0 + n/2)
sage: rsolve_hyper([-2,1], 2^(2+n), n)
2**n*C0 - 2**(n + 2)

Change History (2)

comment:1 Changed 4 years ago by jdemeyer

  • Description modified (diff)

comment:2 Changed 4 years ago by jdemeyer

  • Dependencies set to #24067
Note: See TracTickets for help on using tickets.