# Make a “ditch” function for electric field purpose

I'm trying to make a function to simulate a finite bar and get the electric field, i did it by put 22 funnels together but is too slow and is not very accurate; does anyone have any function to replace this thing?

PD: this function is:

Total[Table[1/Sqrt[x^2 + (y + i)^2], {i, -5, 5, 0.5}]]


Final Result:

Thanks!

-
How about just replacing the summation with an integral? Integrate[1/Sqrt[x^2 + (y + t)^2], {t, -5, 5}, Assumptions -> {x, y} \[Element] Reals] – Rahul Apr 9 '14 at 18:10
I love you! it works – Gonzalo Apr 9 '14 at 18:13

f[x_, y_] := Evaluate[Integrate[1/Sqrt[x^2 + (y + t)^2], {t, -5, 5},

The assumptions are helpful because otherwise Mathematica assumes $x$ and $y$ to be complex, and spends a much longer time getting to essentially the same result.