Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to write and evaluate an expression something like $$H_1=\sum_{i+j=0}^3 e_{ij}x^iy^j$$


$$H=\frac{\sum_{i+j=0}^3 e_{ij}x^iy^j}{\sum_{i+j=0}^3 a_{ij}x^iy^j}$$

with correct syntax.

share|improve this question

closed as off-topic by belisarius, Michael E2, RunnyKine, Jens, ciao May 25 '14 at 22:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – belisarius, Michael E2, RunnyKine, Jens, ciao
If this question can be reworded to fit the rules in the help center, please edit the question.

What are the bounds on i and j? –  wolfies May 25 '14 at 15:31
The problem comes from bounds, you need two sums, one for (i+j=) k=0 to 3, and one for i=0 to k (and infer j=k-i). Assuming i and j are both positive or zero: Sum[e[i, k - i] x^i y^(k - i), {k, 0, 3}, {i, 0, k}]/ Sum[a[i, k - i] x^i y^(k - i), {k, 0, 3}, {i, 0, k}] –  user10957 May 25 '14 at 15:31
h1[x_, y_, n_] := Sum[e[i, n - i] x^i y^(n - i), {i, n}] –  belisarius May 25 '14 at 15:32

1 Answer 1

up vote 0 down vote accepted

I like belisarius' neat suggestion ... but for more general problems you could insert a Boole to take care of any constraint you care to impose. For example:

 Sum[Boole[0 <= i + j <= 3] myFunc[i, j] x^i y^i, {i,0,3}, {j,0,3}]

which returns:

myFunc[0, 0] + myFunc[0, 1] + myFunc[0, 2] + myFunc[0, 3] + x y myFunc[1, 0] + x y myFunc[1, 1] + x y myFunc[1, 2] + x^2 y^2 myFunc[2, 0] + x^2 y^2 myFunc[2, 1] + x^3 y^3 myFunc[3, 0]

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.