  We study a variational wave function for the ground state of the
two-dimensional S=1/2 Heisenberg antiferromagnet in the valence bond basis. The
expansion coefficients are products of amplitudes h(x,y) for valence bonds
connecting spins separated by (x,y) lattice spacings. In contrast to previous
studies, in which a functional form for h(x,y) was assumed, we here optimize
all the amplitudes for lattices with up to 32*32 spins. We use two different
schemes for optimizing the amplitudes; a Newton/conjugate-gradient method and a
stochastic method which requires only the signs of the first derivatives of the
energy. The latter method performs significantly better. The energy for large
systems deviates by only approx. 0.06% from its exact value (calculated using
unbiased quantum Monte Carlo simulations). The spin correlations are also well
reproduced, falling approx. 2% below the exact ones at long distances. The
amplitudes h(r) for valence bonds of long length r decay as 1/r^3. We also
discuss some results for small frustrated lattices.
