Skip to main content
2 of 4
added 160 characters in body

Create lists like this:

g = {1, 2, 3, 4}
h = {10, 20, 30, 40}

Then you can sum like this:

Sum[g[[i]] h[[i]], {i, Length[g]}]

or more nicely (Mathematica does element-wise operations automatically where applicable):

Total[g*h]

You can use this feature to easily calculate a new list with the results, without using indices:

f = (g h)/Total[g h]

{1/30, 2/15, 3/10, 8/15}