Hello to all,

At the moment we need transform a symbolic expression from 'sage' to 
'sympy',

for explicit functions, sage works fine :

sage: b = sin(x)
sage: type(b)
<type 'sage.symbolic.expression.Expression'>

sage: type(sin)
<class 'sage.functions.trig.Function_sin'>

sage: a=b._sympy_()
sin(x)

sage: type(a)
sin   # this is strange!


and viceversa 

import sympy

sage: x=sympy.symbols('x')
sage: type(x)
<class 'sympy.core.symbol.Symbol'>

sage: a=sympy.sin(x)
sage: type(a)
sin

sage: b=a._sage_()
sage: type(b)
<type 'sage.symbolic.expression.Expression'>



But when we use a symbolic function the conversion does not work:

sage: a = function('A')(x,y)

sage: type(A)
<class 'sage.symbolic.function_factory.NewSymbolicFunction'>

sage: type(a)
<type 'sage.symbolic.expression.Expression'>

sage: a._sympy_()
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-101-eeb95aeda6e6> in <module>()
----> 1 a._sympy_()

/home/mmancini/Sage-last/sage/src/sage/symbolic/expression.pyx in 
sage.symbolic.expression.Expression._sympy_ 
(/home/mmancini/Sage-last/sage/src/build/cythonized/sage/symbolic/expression.cpp:11582)()
   1441         """
   1442         from sage.symbolic.expression_conversions import sympy
-> 1443         return sympy(self)
   1444 
   1445     def _algebraic_(self, field):

/home/mmancini/Sage-last/sage/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc
 
in __call__(self, ex)
    224             return self.tuple(ex)
    225         else:
--> 226             return self.composition(ex, operator)
    227 
    228     def get_fake_div(self, ex):

/home/mmancini/Sage-last/sage/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc
 
in composition(self, ex, operator)
    765             return f_sympy(*sympy.sympify(g, evaluate=False))
    766         else:
--> 767             raise NotImplementedError("SymPy function '%s' doesn't 
exist" % f)
    768 
    769 sympy = SympyConverter()


We are doing some mistakes or the conversion function 
(expression_conversions.SympyConverter) is not complete ?
And in other sense (sympy => sage) 

sage: f=sympy.Function('F')
sage: x=sympy.symbols('x')

sage: a=f(x)
sage: a
F(x)

sage: a.diff()
Derivative(F(x), x)

sage: type(f)
<class 'sympy.core.function.UndefinedFunction'>

but 

age: a._sage_()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-124-995abf46eb43> in <module>()
----> 1 a._sage_()

/home/mmancini/Sage-last/sage/local/lib/python2.7/site-packages/sympy/core/function.pyc
 
in _sage_(self)
    705         import sage.all as sage
    706         fname = self.func.__name__
--> 707         func = getattr(sage, fname)
    708         args = [arg._sage_() for arg in self.args]
    709         return func(*args)

AttributeError: 'module' object has no attribute 'F'



There is a solution or have we to implement the symbolic functions 
conversion ? 

Any suggestion?

Thanks,
Marco

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to