I just want to format a simple set theory example. But the following is annoying:

See how close the cap gets to the 'A' because of the tilde sign? I've used sim for the tilde sign. Any suggestions?
I just want to format a simple set theory example. But the following is annoying:

See how close the cap gets to the 'A' because of the tilde sign? I've used sim for the tilde sign. Any suggestions?
You could avoid the binary operator spacing by writing {\sim} or \mathord{\sim}, achieving the same. You might have another look at Spacing around a character in math mode.
You could use one of the following commands:
\, (\thinspace)
\: (\medspace)
\; (\thickspace)
\quad
\qquad
(They generate different spaces, but I don't know how to mark them in the code.) See also the short math guide, p. 11.
EDIT: This solution should't be used here (see comments below). However, I'll not delete it as there is no harm to know about these commands.
I believe it's doing that because \sim is meant as a binary operator (between two elements), rather than as a unary prefix operator (like set complement or negation).
You can always manually fix it up with extra space \; or negative space \! so for example, this looks approximately right:
A\; \cap \sim\!\!B
Here is a complete code example with output (I just took Stefan's answer and wrote it out).
\documentclass{standalone}
% TEX.SE \url{}
\setlength{\textwidth}{4in}
\begin{document}
\Huge
$A = (A \cup B)$
$A \cap (( A) \cap B) = A \cap \mathord{\sim}B$
\end{document}

Switching in and out of math mode is not a good way to get extra spaces. If you still want them after classifying the tilde as an ordinal, you can insert them with \,, \; , or \ . See Herbert's mathmode document for FMTYEWTK.