Magnetic fields tied to ions can diffuse through mostly neutral gas: t
his occurs in protostellar disks and in the cores of molecular clouds.
We describe an algorithm that includes ambipolar diffusion in the ast
rophysical magnetohydrodynamics code ZEUS. We use the approximations t
hat both electrons and ions have equal and constant temperature, that
the ion inertia is negligible, and that the ion density is proportiona
l to a power of the neutral density. Our algorithm is fully explicit,
and treats the magnetic field using constrained transport and the meth
od of characteristics. We test the algorithm by computing the gravitat
ional collapse of a magnetically supported slab, and by comparing the
computed solution for an oblique C-shock to a semi-analytic solution t
hat we have derived. We then compute the development of the magnetorot
ational instability described by Balbus and Hawley in a magnetized acc
retion disk, including the effects of ambipolar diffusion. Our computa
tion agrees with the published linear analysis of how diffusion preven
ts instability, and it allows us to describe the nonlinear development
of the instability when diffusion is important but not dominant. We f
ind that ambipolar diffusion indeed creates the sharp structures predi
cted by Brandenburg and Zweibel.