Concerning Sum: the same problem as integral (repeated sampling). About the noninteger limits: it seems to transform sum into an integral, but I guess this is just a coincidence/implementation detail somewhere in sympy and not anything documented.
About cse and other optimizations: Matthew has written some interesting things about using sympy to optimize numerics on his blog. Slightly offtopic: there is a flag that can be set when plotting so that the lineplot is in a staircase pattern. It is quite useful, for instance, when making plots about approximations of integrals or plots of Sum. It is described in the plot_advanced notebook in the examples folder. On 29 July 2013 20:38, Aaron Meurer <[email protected]> wrote: > The same problem as Integral sampling or the same problem as > DiracDelta (how is Sum defined for non-integer limits?). > > I think in general we should expand out the computation to a symbolic > formula and use cse() to make it more efficient (what's the point of > being symbolic if we can't do cool tricks like this). > > Aaron Meurer > > On Mon, Jul 29, 2013 at 12:35 PM, Stefan Krastanov > <[email protected]> wrote: > > There is also `Sum(1/x**constant, (x, 1, t))` plotted for t in [1, 10] > that > > exhibits the same problem. > > > > > > On 29 July 2013 19:33, Stefan Krastanov <[email protected]> > wrote: > >> > >> The fallback is just to call `evalf` instead something like `lambdify`. > It > >> is always slower, but works even on the most bizarre expressions. For > >> integrals, indeed, there are many points that are resampled with this > naive > >> solution (the algorithm becomes n^2 instead of n). > >> > >> Numeric libraries like scipy provide routines for doing this in a single > >> pass, however one provides the points to be sampled beforehand. mpmath > which > >> is used in this case does not provide this as far as I know. > >> > >> Even if it is provided we will have to somehow link this routine to > >> `Integral.evalf`, because if we just write a special case for the > plotting > >> module, it will work for `Integral(...)` but not for something more > general > >> like `exp(Integral(...))` or `x*Integral(...)`. > >> > >> So yes, we can implement the single-pass algorithm, but it will require > >> some creativity so 1) it will work without us explicitly telling the > >> algorithm beforehand which points are to be sampled and 2) it is > callable > >> like an ordinary `evalf`. > > > > > > -- > > You received this message because you are subscribed to the Google Groups > > "sympy" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to [email protected]. > > To post to this group, send email to [email protected]. > > Visit this group at http://groups.google.com/group/sympy. > > For more options, visit https://groups.google.com/groups/opt_out. > > > > > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
