I have a summation function q[i]*f[j] which runs over i and j of same length with different limits. Following I provided an example, where q is in list form:


and f[j] runs over -1, 0 and 1. The output of this summation function should be:

ouptput= 2*f[-1]+7*f[0]+11*f[1];

So far, I have been able to iterate f[j] over j and using Sum to add, as following:

In: Sum[f[j], {j, -1, 1}]
Out: f[-1] + f[0] + f[1]

But how to iterate q[i] values provided in listform above and multiply to f[j] finnaly get following:

ouptput= q[[1]]*f[-1]+q[[2]]*f[0]+q[[3]]*f[1];

thanks in advance.


1 Answer 1


use a vector product:

q = {2, 7, 11};
jval = Range[-1, 1];

q . (f /@ jval)
(*    2 f[-1] + 7 f[0] + 11 f[1]    *)
  • $\begingroup$ Thank you very much, It worked. $\endgroup$
    – Aman
    Apr 16, 2021 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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