I have written a program in cpp that computes the magnetic field at a point from a current carrying loop. It uses the biot savart law and the monte carlo technique to carry out the integral. The program functions as expected for points that are not too close to the loop but from looking at a plot of the vectors you can see strange errors close to the loop.
I checked my results against http://hyperphysics.phy-astr.gsu.edu/hbase/magnetic/curloo.html#c3 for a point on the axis and http://www.netdenizen.com/emagnet/offaxis/iloopcalculator.htm for a point off the axis. My program agrees with these sources for points not too close to the loop.
This is my code. http://pastebin.com/4BH9qEZz
My main question is if there is anything inherent in the monte carlo technique that would cause this error?
