# Magnetic field in center of a wire with hexagonal cross section

I already know how to calculate magnetic field inside a current carrying wire with Ampere's law. LINK But I can't figure what we can do about wires with non-circular cross sections like rectangular or hexagonal.

I think calculation of the magnetic field in every position inside the wire may need numerical calculation but can we find an analytical solution for the center of the wire?

If not what is the right numerical approach?

Hint: the hardest part of applying Ampere's law is probably calculating the current inside the loop of the integral. When the current is distributed uniformly, you have to realise that the current per unit area in the wire equals $\frac{I_{total}}{A}$. The current enclosed by a loop is then the area of the wire enclosed by this loop multiplied with the current per area. In the case of a circular loop with radius R, the current enclosed by a circular loop becomes:

$$\frac{I_{total}}{A_{total}} . A_{loop}= \frac{I_{total}}{\pi R^2}.\pi r^2$$

So when you're dealing with a rectangular or hexagonal wire, you have to calculate the area of the wire and substitute this in the equation as the total area of the wire.