kcrisman wrote:
On Wednesday, June 12, 2013 8:09:02 PM UTC-4, leif wrote:

    robin hankin wrote:
     > hello,  sage 5.9
     >
     > If solve() gives an unspecificed integer, how do I substitute a
     > particular value into the expression?
     >
     > subs() does not work as expected/desired because the free variables
     > don't seem to be defined.
     >
     > sage: a=solve(sin(x)==0,x,to_poly_solve='force');a
     > [x == 2*pi*z38, x == pi + 2*pi*z36]
     > sage: a[0].rhs()
     > 2*pi*z38
     > sage: a[0].rhs().subs(z38,3)
     >
    ---------------------------------------------------------------------------

     > NameError                                 Traceback (most recent
    call last)
     > <ipython-input-3-1ded925632b3> in <module>()
     > ----> 1 a[Integer(0)].rhs().subs(z38,Integer(3))
     >
     > NameError: name 'z38' is not defined
     > sage:

    Smells like a bug...


Not exactly.  The documentation for solve makes it clear (I hope!) in
the examples that these are "generic" variables generated by Maxima
which we do not make "Sage" variables.  They just mean, "any old
integer" (hence 'z').  That said, it would be useful to allow them to be
used in this way.  The problem is that a user might already have defined
z38 to mean something else...

Well, in the latter case, Sage should be able to automatically rename them to avoid name clashes... ;-)


Or at least .subs() should also work with ('z36',3), say, i.e., strings representing variable names, or dictionaries mapping these to expressions (or concrete values, probably with typechecking...).


-leif

--
() The ASCII Ribbon Campaign
/\   Help Cure HTML E-Mail

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


Reply via email to