William Stein wrote:
> On Fri, Oct 10, 2008 at 7:11 AM, Jason Grout
> <[EMAIL PROTECTED]> wrote:
>> How do I get a numeric approximation for symbolic expressions that have
>> variables?  I want to leave the variables alone, but get numeric
>> approximations for all constants.  For example, here's how it works in
>> mathematica:
>>
>> In[1]:= a:=1+Sqrt[2]*x
>>
>> In[2]:= a
>>
>> Out[2]= 1 + Sqrt[2] x
>>
>> In[3]:= N[a]
>>
>> Out[3]= 1. + 1.41421 x
>>
>>
>> However, the corresponding thing does not work in Sage:
>>
>> sage: a=1+sqrt(2)*x
>> sage: a
>> sqrt(2)*x + 1
>> sage: n(a)
>> ---------------------------------------------------------------------------
>> TypeError                                 Traceback (most recent call last)
> 
> For polynomials, do this:
> 
> sage: f = 1 + sqrt(2)*x
> sage: f.polynomial(RDF)
> 1.41421356237*x + 1.0


Aah, thanks.  I guess I also now see the f.series command, which does 
what I originally wanted as well (lets me specify the ring for the 
coefficients to the series approximation).

The general request still stands, though: is there a way to numerically 
approximate all the constants in a symbolic expression, but keep the 
variables as variables?

Thanks,

Jason


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to