(* This notebook attempts to calculate a more accurate B field due to the coiling of the wire *)

Clear[z,Rloop,Dloop,μ0,Current,Turns]

Bloop =μ0 Current Turns Rloop^2 /2((Rloop^2+(z-Dloop/2)^2)^(-3/2)-(Rloop^2+(z+Dloop/2 )^2)^(-3/2));
SeriesB=Series[Bloop,{z,0,1}];
GradientB = D[SeriesB,z]
(* This gives the same answer as simplifying the actual derivative of B *)

in = 0.254m;
cm = 0.01m;
T=10000G;

μ0 = 4Pi 10^-7 T m/A;
RCoil = 7.459in; (* Center *)
DCoil = 3.620in;(* Center *)

Current = 3A;
Turns = 416;
WireDiameter = 0.0286in;

TurnWidth = Round[Turns^(1/2)]^2;
RInside = RCoil-TurnWidth WireDiameter/2


Rloop={};
For[i=0,i<TurnWidth,Rloop={Rloop,-i}