# Summing over a list

I intend to sum a series over two lists which I generate myself. However, my code is not working. What is the best way to do this? Thanks. Find my code below

w = {5, 1, 2, 2, 8};
x = {0.5, 0.8, 4.6, 3.2, 5};
r = 1;
mysum = Sum[
w[i]*Exp[10^(((-Sqrt[2])*2*x[i] - 2*r)/10)], {i, 1, Length[w]}]


Edit 1 Further to this question, Let's suppose r is a list. How do I sum over to this list to my results equal to the length of r.

The code is below

w = {5, 1, 2, 2, 8};
x = {0.5, 0.8, 4.6, 3.2, 5};
r = {1, 2, 3, 4, 5};
mysum = Map[Total[w[*Exp[10^(((-Sqrt[2])*2*x - 2*r)/10)]], r]

• replace w[i] with w[[i]] and x[i] with x[[i]] – kglr Jul 3 '18 at 7:28
• You can also use the Dot function, as w . Exp[10^(((-Sqrt[2])*2*x - 2*r)/10)] – LouisB Jul 3 '18 at 7:57

Here is an alternative approach. Consider that many numeric Mathematica functions are Listable. Look at the following

w = {5, 1, 2, 2, 8};
x = {0.5, 0.8, 4.6, 3.2, 5};
r = 1;

Sqrt[w]
(* {Sqrt[5], 1, Sqrt[2], Sqrt[2], 2 Sqrt[2]} *)


You provide a list to Sqrt and it knows that it needs to be applied on each element. If you know this, you can use exactly the same in your expression and then you sum all elements together using Total

Total[w*Exp[10^(((-Sqrt[2])*2*x - 2*r)/10)]]
(* 21.7645 *)