1 | initial version |

I figured out that the "subs" command in sympy is far more powerful than substitute in sage. So I converted the sage expression into sympy expression using f=f._sympy_() then did the substitution I wanted to do and after the substitution converted to sage again using f=f._sage_(). The problem is that sympy gives a problem because it cannot recognize i. So I declared a variable name i and restored it in the end. Here is an example script. It would be awesome though if the sage substitute command worked like the sympy subs command.

from sympy import Symbol, cos, sympify, pprint

from sympy.abc import x

x=var('x')

z=var('z')

i=var('i')

f=x*x+x*i+1

view(f)

f=f._sympy_()

view(f)

f=f.subs(x*x,z)

f=f._sage_()

view(f)

restore('i')

2 | No.2 Revision |

I figured out that the "subs" command in sympy is far more powerful than substitute in sage. So I converted the sage expression into sympy expression using f=f._sympy_() then did the substitution I wanted to do and after the substitution converted to sage again using f=f._sage_(). The problem is that sympy gives a problem because it cannot recognize i. So I declared a variable name i and restored it in the end. Here is an example script. It would be awesome though if the sage substitute command worked like the sympy subs command.

`from sympy import Symbol, cos, sympify, `~~pprint~~pprint
~~ ~~from sympy.abc import ~~x~~

x
x=var('x')
x=var('x')

z=var('z')
i=var('i')
z=var('z')

f=x*x+x*i+1
view(f)
i=var('i')

f=f._sympy_()
view(f)
f=x*x+x*i+1

f=f.subs(x*x,z)
f=f._sage_()
view(f)

view(f)
restore('i')

f=f._sympy_()

view(f)

f=f.subs(x*x,z)

f=f._sage_()

view(f)

restore('i')

3 | formatting |

I figured out that the "subs" command in sympy is far more powerful than substitute in sage. So I converted the sage expression into sympy expression using f=f._sympy_() then did the substitution I wanted to do and after the substitution converted to sage again using f=f._sage_(). The problem is that sympy gives a problem because it cannot recognize i. So I declared a variable name i and restored it in the end. Here is an example script. It would be awesome though if the sage substitute command worked like the sympy subs command.

`from sympy import Symbol, cos, sympify, `~~pprint
~~pprint
from sympy.abc import x
~~ ~~x=var('x')
~~ ~~z=var('z')
~~ ~~i=var('i')
~~ ~~f=x*x+x*i+1
~~ ~~view(f)
~~ ~~f=f._sympy_()
~~ ~~view(f)
~~ ~~f=f.subs(x*x,z)
~~ ~~f=f._sage_()
~~ ~~view(f)
~~ ~~restore('i')

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.