Algebraic versus topological line bundles

Let $X$ be a CW complex. The (isomorphism classes of) complex line bundles on $X$ are classified by the homotopy classes of maps $X \to \mathbb{CP}^\infty$, that is by the elements of $H^2(X, \mathbb{Z})$.
It is also true that the tensor product of line bundles corresponds to adding cohomology classes. It follows that if $n \in \mathbb{N}$, then the line bundles of $\mathbb{CP}^n$ are generated by the tensor powers of the tautological line bundle, or, equivalently, by the tensor powers of the sheaf typically denoted $\mathcal{O}(1)$ in algebraic geometry (because the dual of $\mathcal{O}(1)$ is the tautological bundle).

It is also true that the isomorphism classes of algebraic line bundles on $\mathbb{CP}^n$ forms a group isomorphic to $\mathbb{Z}$, given by the powers of $\mathcal{O}(1)$, as one can see by studying the Weil class group. It follows that the isomorphism classes of line bundles are the same in both the algebraic and the topological category.

The above observation is also true for affine $n$-space, because the topological line bundles are trivial ($\mathbb{C}^n$ being contractible), and the algebraic ones are as well (the polynomial ring being a UFD).

To what extent is this true in general?

Solutions Collecting From Web of "Algebraic versus topological line bundles"

Let $X$ be a complex analytic space. There is an exact sequence, the exponential exact sequence, which is of fundamental importance for analyzing this (and related) questions:

$$ 0 \to 2 \pi i \mathbb Z \to \mathcal O_X \buildrel \exp \over \longrightarrow \mathcal O^{\times}_X \to 1 .$$

Assume now that $X$ is proper and connected. When we pass to cohomology, the sequence of $H^0$s is then short exact, but we obtain the following crucial long exact sequence:
$$H^1(X, 2 \pi i \mathbb Z) \to H^1(X,\mathcal O_X) \to Pic(X) \to
H^2(X,2 \pi i \mathbb Z) \to H^2(X,\mathcal O_X).$$
Here I am writing (as is usual) $Pic(X)$ to denote $H^1(X,\mathcal O_X^{\times})$, the group of isomorphism classes of analytic line bundles on $X$. If $X$ is algebraic, then by GAGA this is the same as the group of algebraic line bundles on $X$.

The boundary map $Pic(X) \to H^2(X,2 \pi i \mathbb Z)$ is the Chern class map
(with a $2\pi i$ twist, or Tate twist; this is natural in the algebraic context, and to get the topological Chern class you just divide through by
$2 \pi i$).

So that we see that the kernel of the Chern class map can be identified with
$H^1(X,\mathcal O_X)/H^1(X,2 \pi i\mathbb Z)$, and vanishes when $H^1(X,\mathcal O_X) = 0$.

The image of $Pic(X)$ under the Chern class map is called the Neron–Severi group; its kernel is denoted $Pic^0(X)$ or $Pic^{\tau}(X)$. When $X$ is algebraic, $Pic(X)$ is naturally an algebraic group, $Pic^0(X)$ is the connected component of the identity, and $H^1(X,\mathcal O_X)$ is the tangent space to the identity.

If $X$ is a smooth projective curve, then $Pic^0(X)$ is usually called the Jacobian of $X$. You can look at the section of Hartshorne in Chapter IV to get some sense of it, although you may not realize from reading that how fundamental the role of the Jacobian is in the theory of algebraic curves. If you google Torrelli theorem, Abel–Jacobi theorem, and theta divisor (just to give some sample search terms) you will get some sense of it. Griffiths and Harris also has a detailed discussion, which gives a better sense of its significance.

If $X$ is algebraic but not proper, then you can compacitify it by adding a divisor at infinity. Let me write $\overline{X}$ for the compacification, and let me assume that $\overline{X}$ is in fact smooth, so then the divisor $D := \overline{X}\setminus X$ is a Cartier divisor, and gives rise to an associated line bundle $\mathcal O(D) \in Pic(\overline{X}).$ (This is denoted
$\mathcal L(D)$ in Hartshorne, I think, and in some other texts, especially older ones, but $\mathcal O(D)$ is more common notation these days, and is better notation too.) If $D$ is reducible (as can happen; in general it can be taken to be a normal crossings divisor, but no better — e.g. to compactify a curve to a smooth projective curve, we have to add in a finite number of points, but one point will not be enough, typically), write it as
$D_1 \cup \cdots \cup D_n$.

Then we also have associated line bundles $\mathcal O(D_i)$ for each $i$, whose product is $\mathcal O(D)$, and note that each of these is trivial when restricted to $X$ (because $X = \overline{X} \setminus D$). One now sees
that $Pic(X) = Pic(\overline{X})/\langle \mathcal O(D_1),\ldots,\mathcal O(D_n)
\rangle,$ and so if $Pic^0(\overline{X})$ is non-trivial, then $Pic(X)$ will also have a non-discrete part (because we can’t kill a connected algebraic group by quotienting out a finitely generated subgroup).

So the answer to your question is, at least for smooth $X$, is: compactify $X$ to $\overline{X}$, and then compute $H^1(\overline{X}, \mathcal O)$; if this is non-trivial, then the Chern class map has a (huge!) kernel.

[Added later: As an example, if $X$ is a hypersurface in $\mathbb P^n$ for $n > 2$ (so $X$ has dimension $> 1$), then $H^1(X,\mathcal O_X) = 0$ (exercise!), and so hypersurfaces give interesting examples.

For a surfaces, the dimension $H^1(X,\mathcal O_X)$ was classically (i.e. by the Italians) known as the irregularity of the surface $X$. (The reason being that they knew formulas, like Riemann–Roch, for surfaces in space, which when they tried to extend to more general surfaces became false unless the extra quantity $\dim H^1(X,\mathcal O_X)$ was introduced — although of course they didn’t describe it this way.) See my comment here, as well as the notes of Kleiman linked to by Jason Starr, which will tell you a lot about Picard varieties and much more.]

Deat Akhil, I have nothing to add to Matt E’s masterful survey on the algebraic/analytic comparison. However since you ask about topological line bundles, you have to modify his answer in the following way.

You must replace everywhere $\mathcal O$ by $\mathcal C$, the sheaf of continuous functions. Now things are very easy: since $\mathcal C$ is soft (fine if you prefer), it is acyclic and so the map
$Pic^{top}(X) \to H^2(X,
\mathbb Z)$ is an isomorphism: a topological line bundle is classified by its Chern class, which lives in the second cohomology group of the space. To put it dramatically: the continuous jacobian is trivial !

For example topological line bundles on a compact Riemann surface are classified by $\mathbb Z$ in stark contrast to the huge Picard variety classifying its algebraic= analytic line bundles. So to answer your question “To what extent is this true in general?” [natural bijection between algebraic and topological line bundles] I would answer, just for the pleasure of using the anglicism : “once in a blue moon”.