simplify expression into summation

42 views
Skip to first unread message

Nova Munch

unread,
Aug 1, 2014, 11:54:38 PM8/1/14
to sy...@googlegroups.com
hello, 

2 questions related to reducing to summation using sympy:

1) lets say i have an expression (x) + (x+1) + (x+2) + (x+3) + (x+4)
is there any function to help me simplify/reduce it to become summation of x over 0 to 4?

along the same line:

2) lets say i have an expression (x[0]*y[0]) + (x[1]*y[1]) + (x[2]*y[2]) + (x[3]*y[3]) + (x[4]*y[4]),
is there any function to help me simplify/reduce it to become summation of x[i]*y[i] over 0 to 4?

perhaps it can't be done in the raw form above, maybe i need to use some annotations or use certain types of special symbols? 

NM

Aaron Meurer

unread,
Sep 6, 2014, 3:56:31 PM9/6/14
to sy...@googlegroups.com
Like

i = Symbol('i')
summation(x + i, (i, 0, 4))

If you are looking for something that generates a summation
automatically, I don't think such a thing exists.

Aaron Meurer
> --
> 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 sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/cc339841-178b-4e41-a98d-f8391b2c9286%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages