A straightforward method is proposed for computing the magnetic field
produced by a circular coil that contains a large number of turns woun
d onto a solenoid of rectangular cross section. The coil is thus appro
ximated by a circular ring containing a continuous constant current de
nsity, which is very close to the real situation when sire of rectangu
lar cross section is used. All that is required is to evaluate two fun
ctions, which are defined as integrals of periodic quantities; this is
done accurately and efficiently using trapezoidal-rule quadrature. Th
e solution can be obtained so rapidly that this procedure is ideally s
uited for use in stochastic optimization, An example is given, in whic
h this approach is combined with a simulated annealing routine to opti
mize shielded profile coils for NMR.