Jason Grout wrote:
> Robert Bradshaw wrote:
>> On Dec 3, 2008, at 10:28 AM, adrian wrote:
>>
>>> In the following code:
>>> sage: x=CC['x'].gen()
>>> sage: type(x)
>>> <class
>>> 'sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_d
>>> ense_field'>
>>> sage: f(x)=sin(x)
>>> sage: type(x)
>>> <class 'sage.calculus.calculus.SymbolicVariable'>
>>>
>>> Is this intended?
>> Yes. Otherwise one would need to write var('x') before writing f(x) =
>> sin(x).
>
> Wow, Sage will redefine symbols that are already existing to accommodate
> what should be a dummy variable? This looks seriously wrong and looks
> like it could really mess things up.
>
> For example:
>
> sage: f(sage) = sin(sage)
> sage: type(sage)
> <class 'sage.calculus.calculus.SymbolicVariable'>
>
> sage: f(i) = i^2
> sage: type(i)
> <class 'sage.calculus.calculus.SymbolicVariable'>
> sage: i^2
> i^2
>
> I would strongly prefer that this is wrapped so that a local symbolic
> variable is used that is not tied to anything, or even just so that the
> value of x is reset after the function is assigned. Are we using
> sage.calculus.calculus.var in the code so that we don't inject into the
> global namespace, just like the docstring of var says?
To be more clear, currently we have:
sage: preparse('f(x)=sin(x)')
'_=var("x");f=symbolic_expression(sin(x)).function(x)'
I would strongly prefer this to be
sage:
_=sage.calculus.calculus.var("y");f=symbolic_expression(sin(_)).function(_)
sage: f
y |--> sin(y)
(or instead of "_", use whatever you can for a temporary variable)
Is there something terrible that would happen in that case?
Jason
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---