TITLE: Two principal ideals coincide if and only if their generators are associated
QUESTION [10 upvotes]: Suppose we have a ring $R$ and $(a),(b)$ are both ideals of $R$. Is it always true that $(a)=(b)$ if and only if there exists a unit $c$ such that $a=bc$ (i.e., $a$ and $b$ are associate)? 

I have already verified that the forwards direction is true. But I have no idea on the backward direction. If it is true, can someone provide a proof to me?
Backward direction: Suppose that there exists a unit $c \in R$ such that $a=bc$. This implies that $(a)\subset (b)$. By using the same thing, (i.e., $b$ and $a$ are associate), there exists a unit $d \in R$ such that $b=ad$. This implies that $(b) \subset (a)$. is this correct?

REPLY [18 votes]: This is easily proved true if $\rm\:a,b\:$ are not zero-divisors. It may fail otherwise, e.g. Kaplansky gave this counterexample: in the ring of continuous
real functions on $[0,3],$ define piecewise $\rm\:a(t)\:$ and $\rm\:b(t)\:$
as follows: $\rm\: a(t) =1\!-\!t=b(t)\:$ on $[0,1];$ both $\,0\,$ on $[1,2];$ $\rm\:a(t)=t-2 = -b(t)$ on $[2,3].$
Kap remarked that the property is true for Artinian rings, principal ideal rings, and rings whose zero-divisors are contained in the Jacobson radical. For much further analysis see
When are Associates Unit Multiples?
D.D. Anderson, M. Axtell, S.J. Forman, and Joe Stickles
Rocky Mountain J. Math. Volume 34, Number 3 (2004), 811-828.

REPLY [9 votes]: This is not quite true over arbitrary (commutative) rings, although it holds over integral domains. From the given condition you get elements $u,v$ so that $b=ua$, $a=vb$ and so $b=uvb$ and $a=vua$. When $a$ or $b$ is a regular element, as always happens in an integral domain (with the exception of the trivial case $a=b=0$) then one can cancel it to conclude that $u$ and $v$ are inverses of each other.
This fails however in more general rings. As happens often with such statements, one can easily force an example by dividing out suitable things from a polynomial ring. Take $R=k[a,b,u,v]/(a-vb,b-ua)$ for some field (or ring) $k$, now we have forced $aR=bR$. However neither $u$ nor $v$ are invertible, as the evaluation $a:=0,b:=0$, which induces a morphism $R\to k[u,v]$ where the images of $u,v$ are non-invertible, shows.