MATLAB: How to find the sum of product

numerical integration

i want to find ∑_{e,r>0}f(e,r)x^e y^r where f(e,r)=∏_{i=1}^{c}(2r+2e-4(2i-1))

Best Answer

i = 1 : c;
f = @(e,r) prod(2*r + 2*e - 4 * (2 * i - 1));
term = @(e,r) f(e,r) .* x.^e .* y.^r;
and now you would sum term(e,r), but I cannot tell from your formula what the variable of summation is or what the limits of the summation are.
For some variations on the limits of summation, you would probably need a "for" loop or equivalent. For other variations on the limits of summation, everything could be vectorized.