Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
magnetic field of a solenoid
plist = Table[{(4 i - 26)/6, -(-1)^i}, {i, 1, 12}];
r[{xi_, yi_}] := Sqrt[(x - xi)^2 + (y - yi)^2];
DensityPlot[
2 Sqrt[((Plus @@
Map[#[[2]] (x - #[[1]])/r[#]^2 &, plist])^2 + (Plus @@
Map[-#[[2]] (y - #[[2]])/r[#]^2 &, plist])^2)] +
Cos[18.8 Plus @@ Map[#[[2]]/r[#] &, plist]] + 1, {x, -6, 6}, {y, -3,
3}, Mesh -> False, Frame -> False, PlotRange -> {0, 10},
PlotPoints -> {275, 138}, AspectRatio -> 1/2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.