Hi, On 16 April 2010 13:03, Ben Goodrich <goodrich....@gmail.com> wrote:
> Hi Mateusz > > On Apr 16, 11:46 am, Mateusz Paprocki <matt...@gmail.com> wrote: > > SymPy can compute things like F*G - H**2 fast, unfortunately not on the > > user level. Below you will find a short tutorial how to do it fast but > > messy way. > > > > Lets assume you have polynomial-like expressions F, G, H. For my own > > convenience, when experimenting, I made my self a function fun() which > > returns those expressions: > > > > In [1]: %time F, G, H, gens = fun() > > CPU times: user 12.03 s, sys: 0.00 s, total: 12.03 s > > Wall time: 12.46 s > > What exactly is gens here? I thought it was supposed to be a list that > contains all the symbols in the polynomials, but then I eventually run > into this error > > /tmp/mattpap-sympy-polys-cd30a32/sympy/polys/polytools.py in > _init_poly_from_list(list_rep, *gens, **args) > 286 > 287 if len(gens) != 1: > --> 288 raise PolynomialError("can't create a multivariate > polynomial from a list") > > gens is just a list of symbols. The error tells you that you can't create multivariate polynomials using nested lists. Use dictionaries instead. E.g.: Poly([1,2,3], x) is ok, but not Poly([[1],[2],[3]], x, y), use Poly({(2,0): 1, (1,0): 2, (0,0): 3}, x, y). > > Thanks, > Ben > > -- > 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 <sympy%2bunsubscr...@googlegroups.com>. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > > Mateusz -- 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.