Message Boards Message Boards

0
|
8311 Views
|
9 Replies
|
5 Total Likes
View groups...
Share
Share this post:

symbolic evaluation of sums not simplifying as expected

Posted 10 years ago

My basic question is, why doesn't this give a better answer

FullSimplify[Sum[(a_i + b_i)*(a_i + b_i), i] - Sum[a_i*a_i, i]]

I would expect it to simplify to something like

Sum[2*a_i * b_i + b_i * b_i, i] 

but instead it leaves the two sums intact.

Interestingly, it does this if I remove the _i from all of the variables, but adds an inexplicable product by "i", returning:

b (2 a + b) i

Any ideas for how I can get this to work?

POSTED BY: Paul Bailey
9 Replies

Given the goal, I wonder if the following approach might be of use. You are operating on explicit Sum objects. Perhaps commute this, that is, do the operation(s) on the general form of the jth term first, and then Sum over j.

POSTED BY: Daniel Lichtblau
Posted 10 years ago

Jim,

The note about sums is helpful but what I'm looking for is a simplification that thinks that summation symbol is a helpful option, so

a1 + a2 + a3 + a4 + a5

is actually more fully simplified when written

Sum[a[[i]], {i,n}]

I don't see that I can get that in Mathematica itself. Does mathStatica offer that?

also, Daniel, yes a_i didn't do what I wanted in all cases. For example it gets this correct:

FullSimplify[Sum[(a_i + b_i) (a_i + b_i), {i, 1}] - Sum[a_i*a_i, {i, 1}]]

but not this:

FullSimplify[Sum[(a_i + b_i) (a_i + b_i), {i, 1}] - Sum[a_i, {i, 1}] * Sum[a_i, {i, 1}]]

which makes a lot of sense for what I thought it might be doing.

POSTED BY: Paul Bailey
Posted 10 years ago

Jim,

Yes, you are very close to what I want to do except in topic areas--I'm doing statistics not combinatorics. I like what you wrote but I wonder, why should I have to specify n?

I have several vectors and will be taking inner products of them. Well, really, it's just matrix algebra but I want to do it symbolically so that I can perhaps differentiate the result and figure out the sign of some partials. But first, I need the ability to do products of sums and simplify the results.

Daniel,

I should have mentioned that the Sum[..., {i,1}] notation was a hack that appeared to be working, not a solution that I thought represented my thoughts in Mathematica clearly. It does get things right like my first example and some simple ratios do what I expect when I apply Expand[].

POSTED BY: Paul Bailey
Posted 10 years ago

I'm a statistician and use combinatorics in a lot of the work I do. (My major professor who was a statistician co-wrote a book called Combinatorial Chance - I highly recommend looking at that book for some of the things you might want to do with such sums as you've described.)

I also highly recommend the book called Mathematical Statistics with Mathematica written by Colin Rose and Murray Smith (which describes what's in the mathStatica package I mentioned earlier). Chapter 7 deals with augmented symmetric functions.

About specifying n....To figure out general solutions using sums like you've used above sometimes one needs to specify a suite of particular n's and hopefully a pattern will be recognized. Or you try 1, 2, 3, 4, ... and some recursive pattern becomes apparent. But with augmented symmetric functions you won't need to specify n to obtain the general results.

POSTED BY: Jim Baldwin
Posted 10 years ago

It looks like you might be trying to re-invent power sums and symmetric functions used in lots of combinatorial problems (which is a good thing). The power sums and symmetric polynomials are found in Mathematica and the add-on package mathStatica.

Is the following something that you're trying to do?

a = {a1, a2, a3, a4, a5};
    b = {b1, b2, b3, b4, b5};
    n = 5;
    FullSimplify[Sum[(a[[i]] + b[[i]]) (a[[i]] + b[[i]]), {i,n}]/(Sum[a[[i]]^2, {i, n}] + 2*Sum[a[[i]] b[[i]], {i, n}] + Sum[b[[i]]^2, {i, n}])]
POSTED BY: Jim Baldwin

I don't know if you quite realize what you did. Sum[..., {i,1}] will compute an explicit summation asi` goes from 1 to 1. I doubt the resulting simplification implies that Mathematica can do what (I believe) you actually want from it.

POSTED BY: Daniel Lichtblau
Posted 10 years ago

Hi Bruce,

You are right. Thank you very much for helping me with subscripts.

Rewriting my question, this is now my issue. The following, which I believe to be equal to one, does not simplify

FullSimplify[
  Sum[(Subscript[a, i] + Subscript[b, i])*(Subscript[a, i] + Subscript[b, i]), i] /
      (Sum[Subscript[a, i]*Subscript[a, i], i] + 2 * Sum[Subscript[a, i]*Subscript[b, i], i] + Sum[Subscript[b, i]*Subscript[b, i], i])
]

instead it just gives back the pretty printed version of the equation. Interestingly, I was able to use the Blank[] notation to get the behavior that I wanted, so I know Mathematica knows how to do this.

FullSimplify[
  Sum[(a_i + b_i)*(a_i + b_i), {i, 1}]/(Sum[a_i*a_i, {i, 1}] + 2 * Sum[a_i*b_i, {i, 1}] + Sum[b_i*b_i, {i, 1}])
]

returns 1 and does some other algebra that I've tested as I expect, but it does make extremely verbose output.

POSTED BY: Paul Bailey

Are you using "_i" as a notation for subscript? Subscripts in executable code need extra work. See the notebook attachment SubscriptedVariables101.nb in thread http://community.wolfram.com/groups/-/m/t/237039 for suggestions.
For the second draft, try writing the code without subscripts.

If you mean "a_i" to be a variable name, that will not work in Wolfram Language. Underscore is a special character.

In[1]:= ?_                                                                              
_ or Blank[] is a pattern object that can stand for any Wolfram Language expression. 
_h or Blank[h] can stand for any expression with head h. 
POSTED BY: Bruce Miller
Posted 10 years ago

I should mention that I'm not just interested in this type of sum but also sums of the form Sum[ai * bi, i] / Sum[ai * ai, i] where removing the _i would give an incorrect answer.

POSTED BY: Paul Bailey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract