Maybe we should vectorize subs, but in the meanwhile, you can use list 
comprenehsions, and map if you want to evalf:

In [5]: s = x*pi

In [6]: [s.subs(x, i) for i in range(10)]
Out[6]: [0, π, 2⋅π, 3⋅π, 4⋅π, 5⋅π, 6⋅π, 7⋅π, 8⋅π, 9⋅π]

In [7]: map(N, [s.subs(x, i) for i in range(10)])
Out[7]: [0, 3.14159265358979, 6.28318530717959, 9.42477796076938, 
12.5663706143592, 15.707963267949, 18.8495559215388, 21.9911485751286, 
25.1327412287183, 28.2743338823081]

Also, I think it would be nice to have a subs function that is a wrapper around 
subs like we do with N and evalf so it is easier to map subs to a list (right 
now you would have to use a lambda function).

Aaron Meurer
On Dec 3, 2009, at 6:03 PM, twk wrote:

> Hi,
> I am relatively new to sympy but like it and try to use it for my
> calculations.
> 
> Now, I would like to use symbolic terms for further numeric
> calculations.
> I tried to use something like .subs(x,range(20)) but it did not work.
> Is there a way to treat symbols in a symbolic expression like a list
> or matrix?
> 
> Would be great if somebody could help me!
> 
> Thanks,
> twk
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to 
> sympy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sympy?hl=en.
> 
> 

--

You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.


Reply via email to