Greetings,

I am a completely new to SAGE as of a few days ago.  I have used Maple
and Mathematica for years, and it is easy to do what I am describing
below in those systems.  I assume it is also easy to do in sage, but I
have not been able to find it in the documentation.

Here's the story:

I am attempting to write a sage function where I need to solve a
system of equations, and then plug these solutions into an expression,
and then process the result further.

Since the solutions to the system come wrapped in brackets, and
subs_expr expects the substitution equations without any brackets
around them I do not see how to do this.

Here is a toy example in interactive mode:
***********************************************************************
sage: y=var('y')
sage: z=var('z')
sage: solns = solve( [x+y+z==5, y+z==3, x+z==1], [x,y,z])
sage: solns
[[x == 2, y == 4, z == -1]]
sage: ( x + y + z ).subs_expr(solns)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call
last)

/Users/andrewsills/.sage/<ipython console> in <module>()

/Applications/sage/local/lib/python2.5/site-packages/sage/calculus/
calculus.pyc in subs_expr(self, *equations)
   3922         for x in equations:
   3923             if not isinstance(x, SymbolicEquation):
-> 3924                 raise TypeError, "each expression must be an
equation"
   3925         R = self.parent()
   3926         v = ','.join(['%s=%s'%(x.lhs()._maxima_init_(), x.rhs
()._maxima_init_()) \

TypeError: each expression must be an equation
*****************************************************************************
However, if I manually cut and paste my solutions into the expression,
I get the desired result:

*******************************************************************
sage: ( x + y + z ).subs_expr(x == 2, y == 4, z == -1)
5
*******************************************************************

Of course, I cannot manually cut and paste in the middle of a
function.
So, it would seem that I either need to find a way to, in effect,
remove the brackets that naturally occur in [[ x == 2, y == 4, z ==
-1 ]], or alternatively, find another way to substitute into ( x + y +
z ) where it is acceptable to have the brackets there.

I am sure this is extremely simplistic, and I appreciate your
patience.

Thanks,
Drew

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to