Skip to content
Tutorials Center
My learning

Topics

Lesson 26 of 38 · Magnetism and Magnetic Fields

Magnetic Fields Produced by Currents

Discover how currents create magnetic fields: the Biot-Savart law, Ampere's law, and the fields of a straight wire, circular loop and solenoid, with calculations.

In 1820 the Danish physicist Hans Christian Ørsted noticed that a compass needle twitched when he switched a current on in a nearby wire. Electricity and magnetism, previously thought separate, were linked: moving charges create magnetic fields. Every magnet is, at its core, a collection of tiny currents (electrons in atoms), and every electromagnet is a current-carrying coil.

This lesson gives you the formulas for the fields you will meet most: a long straight wire, a circular loop and a solenoid. It also introduces the two laws behind them.

The field of a long straight wire

A long straight wire carrying current I produces field lines that are circles around the wire. At distance r the magnitude is

Text
B = μ₀ I / (2π r)

where μ₀ = 4π×10⁻⁷ T·m/A is the permeability of free space. The direction follows the right-hand grip rule: point your right thumb along the current and your curled fingers show the direction of the field lines.

The field falls off as 1/r: twice as far gives half the field.

Worked example

A wire carries 10 A. At 5.0 cm away:

B = (4π×10⁻⁷ × 10) / (2π × 0.050) = 2×10⁻⁷ × 10 / 0.050 = 4.0×10⁻⁵ T = 40 μT.

That is comparable to the Earth's field, so a compass near such a wire would be thrown off noticeably.

Python Field of a straight wire versus distance

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The Biot–Savart law

For other shapes, we build the field by adding up the contribution of each small piece of wire. The Biot–Savart law says that a short element dl carrying current I makes, at a point whose position relative to the element is r (length r, unit vector r̂), the field

Text
dB = (μ₀ / 4π) × I dl × r̂ / r²

The cross product means dB is perpendicular to both the element and the line to the point. Summing (integrating) over a long straight wire gives the formula above.

The field of a circular loop

At the center of a circular loop of radius R with N turns:

Text
B = μ₀ N I / (2 R)

Every piece of the loop contributes a field in the same direction at the center (along the axis), which is why the formula is so simple. Along the axis at a distance x from the center, the field is

Text
B = μ₀ N I R² / (2 (R² + x²)^(3/2))

Use the right-hand rule again: curl your fingers along the current, and your thumb points along the field on the axis. A flat loop therefore behaves like a small bar magnet, with a north face where the field lines exit.

Python Axial field of a circular coil

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Ampère's law

For highly symmetric currents there is a shortcut. Ampère's law says that if you add up B · dl around any closed loop (the line integral), you get μ₀ times the current passing through the loop:

Text
∮ B · dl = μ₀ I_enclosed

For a long straight wire, choose a circle of radius r. By symmetry B is the same all the way around and parallel to the path, so the integral is B × 2π r. Setting B × 2π r = μ₀ I gives the result B = μ₀ I / (2π r) immediately, with no integration of pieces. Ampère's law plays the same role for magnetism that Gauss's law plays for electric fields: it is easiest for symmetric situations.

The solenoid

A solenoid is a long coil of wire wound tightly in a helix. Inside, far from the ends, the field is strong and nearly uniform, and outside it is weak. Applying Ampère's law to a rectangular loop partly inside gives

Text
B = μ₀ n I

where n = N / ℓ is the number of turns per unit length. Notice there is no dependence on the solenoid's radius or position inside.

Example: n = 1000 turns/m and I = 2.0 A gives B = 4π×10⁻⁷ × 1000 × 2.0 ≈ 2.5×10⁻³ T (2.5 mT).

If the solenoid is filled with a ferromagnetic core such as soft iron, the field is multiplied by the relative permeability μ_r of the material, often by hundreds or thousands: B = μ_r μ₀ n I. That is why electromagnets use iron cores.

flowchart TB
  A["Wire: B = μ0 I / (2π r)"] --> D["Superposition of pieces"]
  B["Loop: B = μ0 N I / (2R)"] --> D
  C["Solenoid: B = μ0 n I"] --> D
  D --> E["Biot-Savart or Ampere's law"]

All of these follow from the same two laws.

Python Design a solenoid for a target field

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The relative permeability here is only an illustrative number, and real iron saturates at about 1.5 to 2 T, so very large fields cannot be reached by just adding current.

Common mistakes

  • Using n = N instead of N / ℓ in the solenoid formula.
  • Forgetting that the straight-wire formula applies to a long wire, far from its ends.
  • Applying the right-hand grip rule with the left hand.
  • Mixing up the force on a wire in a field with the field made by a wire.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. What is the magnetic field 2.0 cm from a long straight wire carrying 5.0 A? (μ₀ = 4π×10⁻⁷ T·m/A)

    B = μ₀ I / (2π r) = 2×10⁻⁷ × 5.0 / 0.020 = 5.0×10⁻⁵ T.
  2. 2. A solenoid has 800 turns in a length of 0.40 m and carries 3.0 A. What is the field inside?

    n = 800 / 0.40 = 2000 turns/m. B = 4π×10⁻⁷ × 2000 × 3.0 ≈ 7.5×10⁻³ T.
  3. 3. Which law is the most convenient for finding the field of a long straight wire?

    The circular symmetry means B is constant on a circular path, so Ampère's law gives the field directly.

Summary

  • Moving charges create magnetic fields; the direction follows the right-hand grip rule.
  • Long straight wire: B = μ₀ I / (2π r). Circular loop center: B = μ₀ N I / (2R). Solenoid: B = μ₀ n I.
  • The Biot–Savart law sums contributions from small current elements; Ampère's law is the shortcut for symmetric cases.
  • An iron core multiplies a solenoid's field by the relative permeability.

Next: Magnetic Flux and Faraday's Law