if you have two separate current carrying loops of wire in the xz plane, one at y=0 and one at y=L. And each loop carries a current of I in the same direction.

how do you calculate the magnetic field across the y-axis, and what if we have n loops in each of the separate loops?

You can find derivations of this configuration (one coil on top of another, sperated by a certain distance) if you Google the subject "Helmholtz coil". I do not understand what you mean by "loops inside of loops"

To calculate the magnetic field across the y-axis (B_y), caused by two separate current-carrying loops in the xz plane, we can use the Biot-Savart Law. The Biot-Savart Law states that the magnetic field created by a current-carrying wire at a point is directly proportional to the current, length of the wire, and the sine of the angle between the wire and the line connecting the wire to the point.

Let's denote the position of the point where we want to calculate the magnetic field as P(0, y, 0). We will consider a small element dl of the current-carrying wire, and calculate the magnetic field dB created by this element at point P. We can then integrate to sum up the contributions from all the elements of the loop to find the total magnetic field at point P.

The magnetic field dB at a point due to a current element dl is given by:

dB = (μ₀/4π) * (I * dl × r / r³)

Where:
- dB is the magnetic field element created by the current element dl.
- μ₀ is the permeability of free space, equal to 4π × 10^-7 Tm/A.
- I is the current in the wire.
- dl represents the current element.
- × denotes the cross product.
- r is the position vector from dl to point P.
- r³ is the cube of the magnitude of r.

In our case, both loops carry the same current I and are at y = 0 and y = L. So, considering a loop at y = 0, the position vector r is (0, y, 0). For the loop at y = L, the position vector is (0, y - L, 0).

To calculate the total magnetic field at point P due to both loops, we can sum up the contributions from both loops by integrating over their respective paths. Since there are n loops in each separate loop, the integration is taken n times.

B_y = ∫dB = ∮(μ₀/4π) * (nI * dl_1 × r_1 / r_1³) + ∮(μ₀/4π) * (nI * dl_2 × r_2 / r_2³)

Where:
- ∫ denotes the integration.
- ∮ denotes the line integral around the loop.
- dl_1 and dl_2 represent the current elements on the loops at y = 0 and y = L respectively.
- r_1 and r_2 are the position vectors from the current elements to point P.

By performing the integrations over the respective loop paths and taking into account the proper limits, you can calculate the magnetic field B_y across the y-axis.

Note: The above calculations assume that the loops are ideal circular loops with negligible thickness and uniform current distribution.