Re: Simplyfing Sum[Mod[f(k),y],{k,k0,n}] type expressions? (Newbie question)
- To: mathgroup at smc.vnet.net
- Subject: [mg40219] Re: [mg40202] Simplyfing Sum[Mod[f(k),y],{k,k0,n}] type expressions? (Newbie question)
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Wed, 26 Mar 2003 02:42:34 -0500 (EST)
- References: <200303251950.OAA11794@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
prodogoss wrote: > > I'm dealing with a problem that requires lots of summations of (x mod > y) type expressions. I had hoped that Mathematica (which I've just > started using) could simplify these but it doesn't seem to work. > > E.g., why won't (can't?) Mathematica simplify the expression: > > Sum[Mod[3n-k-4, 3],{k, 2n-1,d}] ? > > By *hand* I can show that if > > S = SUM((3n-k-4) mod 3, k = 2n-1 to d) and > > G = d - 2n + 2, then S = f(t) where t = (n - 2 - G) mod 3, and > > (f(0), f(1), f(2)) = ({1, 0, 0}, {0, 1, 0}, {0, 0, 1})(G-1, G, G) > > ie 3x1 matrix = (3rd order unit matix) x (3x1 matrix) > > Hence, given values of d & n, S can be expressed in such a way that > its calculation is possible without having to labourously evaluate S > for each step, k. > > I had heard so much about Mathematica and thought it would excel at > handling problems like this involving summations of Mod[] etc.? Is > there another way of doing this? Any help would be great! > > Thanks in advance! In[1]:= InputForm[PolynomialMod[Sum[3*n-k-4, {k,2*n-1,d}], 3]] Out[1]//InputForm= 2 + d^2 + 2*n + 2*n^2 Alternatively you can do it as you originally intended, but use PolynomialMod rather than Mod as the latter expects NumberQ arguments. In[2]:= InputForm[Sum[PolynomialMod[3*n-k-4,3], {k,2*n-1,d}]] Out[2]//InputForm= 2 + 3*d + d^2 + 2*n - 4*n^2 Note that the results are equivalent via PolynomialMod[...,3]. Daniel Lichtblau Wolfram Research
- References:
- Simplyfing Sum[Mod[f(k),y],{k,k0,n}] type expressions? (Newbie question)
- From: prodogoss@btinternet.com (prodogoss)
- Simplyfing Sum[Mod[f(k),y],{k,k0,n}] type expressions? (Newbie question)