Let $X \to \mathbb P^n$ be a fiber bundle of algebraic varieties with $X$ an affine variety. What is the smallest dimension that $X$ can be?


An obvious lower bound is $n+1$.


An upper bound is $2n$, given by taking the complement of a generic effective divisor of bidegree $(1,1)$ in $\mathbb P^n \times \mathbb P^n$. (Alternatively, take the canonical "duality" $(1,1)$ divisor defined by viewing $\mathbb P^n$ as the Hilbert scheme of hyperplanes on $\mathbb P^n$.) The complement of an effective ample divisor is of course affine, and since the divisor is locally constant on the fibers its complement is as well.


This construction is the construction in [this question](https://mathoverflow.net/questions/101801/projective-spaces-as-affine-varieties/101805#101805), which also inspired my question, with the second condition removed.



Dimension of Affine Bundles on Projective Space
Are you working over the complex numbers? Is $X$ smooth? If so, then I believe you can use the Leray spectral sequence and the Lefschetz hyperplane theorem to quickly deduce that $\text{dim}\_{\mathbb{C}}(X) \geq 2n$. Indeed, denote by $m$ the relative dimension of $X$ over $\mathbb{C}P^n$, so that the (complex) fiber dimension is $m$. Let $p\_0$ be the largest integer such that $H^{p\_0}(Y,\mathbb{Q})$ is nonzero, where $Y$ is the fiber. Now consider the Leray spectral sequence computing the cohomology of the total space, $H^{r}(X,\mathbb{Q})$, starting with the page whose terms are $H^q(\mathbb{C}P^n,H^p(Y,\mathbb{Q}))$ -- I am using that $\mathbb{C}P^n$ is simply connected. In particular, for $q=2n$ and for $p=p\_0$, the term is 
$$H^{2n}(\mathbb{C}P^n,\mathbb{Q})\otimes\_{\mathbb{Q}}H^{p\_0}(Y,\mathbb{Q}),$$
which is nonzero by hypothesis.
In fact there is no nonzero term of higher $p$-degree or $q$-degree, hence there is no nonzero
differential coming into or out of this term at any stage of the spectral sequence. Therefore $H^{2n+p\_0}(X,\mathbb{Q})$ is nonzero. On the other hand, since $X$ is affine, we can use the Lefschetz hyperplane theorem to conclude that $H^d(X,\mathbb{Q})$ is zero for $d$ strictly larger than $\text{dim}\_{\mathbb{C}}(X)$. Thus $n+m \geq 2n+p\_0 \geq 2n$, so that $\text{dim}(X) \geq 2n$.


EDIT: What I refer to as the "Lefschetz hyperplane theorem" is more properly the "Andreotti-Frankel" theorem.


