%This function calculates the potential of and object of charge
%or mass q1 relative to another of q2 a distance r away.
%It uses a fancy equation that Professor Militzer showed me
%from his Thesis. It helps adjust coulomb forces to avoid issues when r is
%very small.

%Henry Peterson 2016

function V = potential(q1,q2,r)

global c
V = q1*q2/norm(r) * ( 1 - exp( -norm(r)^2/c^2 )...
    + sqrt(pi)*norm(r)/c*( 1-erf(norm(r)/c) ) );
