I have a list of this form:
$ lst =\left\{\left\{q_1,x_1,y_1,z_1\right\},\left\{q_2,x_2,y_2,z_2\right\},\text{...},\left\{q_n,x_n,y_n,z_n\right\}\right\} $
I want to use this list in the function:
$V(\{x,y,z\})=\sum _{i=1}^n \frac{q_i}{\sqrt{\left(x_i-x\right){}^2+\left(y_i-y\right){}^2+\left(z_i-z\right){}^2}}$
Where n is the lenght of the list n = Length[lst]. I am not sure how i get this into a inpute code. I have tried the following with the list lst and function v2 :
lst= {{1, 0, 0, 0}, {1, -1, 0, 0}, {1, 1, 0, 0}};
$ \text{V2}(\{\text{x$\_$},\text{y$\_$},\text{z$\_$}\},\text{lst$\_$})\text{:=}\sum _{i=1}^n \frac{\text{lst}[[\text{All},1]]}{\sqrt{\left(\text{lst}[[\text{All},2]]_i-x\right){}^2+\left(\text{lst}[[\text{All},3]]_i-y\right){}^2+\left(\text{lst}[[\text{All},4]]_i-z\right){}^2}}$
V2[{x_, y_, z_}, lst_] :=
Sum[lst[[All,1]]/Sqrt[(Subscript[lst[[All,2]], i] - x)^2 + (Subscript[lst[[All,3]], i] - y)^2 +
(Subscript[lst[[All,4]], i]- z)^2], {i, 1, n}];
Apply[V2, {{x, y, z}, lst}]
Gives : $ \left.\frac{1}{\sqrt{\left(\{0,-1,1\}_2-x\right){}^2+\left(\{0,0,0\}_2-y\right){}^2+\left(\{0,0,0\}_2-z\right){}^2}}+\frac{1}{\sqrt{\left(\{0,-1,1\}_3-x\right){}^2+\left(\{0,0,0\}_3-y\right){}^2+\left(\{0,0,0\}_3-z\right){}^2}}+\frac{1}{\sqrt{\left(\{0,-1,1\}_1-x\right){}^2+\left(\{0,0,0\}_1-y\right){}^2+\left(\{0,0,0\}_1-z\right){}^2}},\frac{1}{\sqrt{\left(\{0,-1,1\}_2-x\right){}^2+\left(\{0,0,0\}_2-y\right){}^2+\left(\{0,0,0\}_2-z\right){}^2}}+\frac{1}{\sqrt{\left(\{0,-1,1\}_3-x\right){}^2+\left(\{0,0,0\}_3-y\right){}^2+\left(\{0,0,0\}_3-z\right){}^2}}+\frac{1}{\sqrt{\left(\{0,-1,1\}_1-x\right){}^2+\left(\{0,0,0\}_1-y\right){}^2+\left(\{0,0,0\}_1-z\right){}^2}},\frac{1}{\sqrt{\left(\{0,-1,1\}_2-x\right){}^2+\left(\{0,0,0\}_2-y\right){}^2+\left(\{0,0,0\}_2-z\right){}^2}}+\frac{1}{\sqrt{\left(\{0,-1,1\}_3-x\right){}^2+\left(\{0,0,0\}_3-y\right){}^2+\left(\{0,0,0\}_3-z\right){}^2}}+\frac{1}{\sqrt{\left(\{0,-1,1\}_1-x\right){}^2+\left(\{0,0,0\}_1-y\right){}^2+\left(\{0,0,0\}_1-z\right){}^2}}\right\}$
But i am expecting to get $\frac{1}{\sqrt{x^2+y^2+z^2}}+\frac{1}{\sqrt{(x+1)^2+y^2+z^2}}+\frac{1}{\sqrt{(x-1)^2+y^2+z^2}} $
What am i doing wrong?
InputForm
). $\endgroup$