We present a simple, robust and efficient method for varying the parameters in a many-body wave function to optimize the expectation value of the energy. The effectiveness of the method is demonstrated by optimizing the parameters in flexible Jastrow factors, that include 3-body electronelectron-nucleus correlation terms, for the NO2 and decapentaene (C10H12) molecules. The basic idea is to add terms to the straightforward expression for the Hessian of the energy that have zero expectation value, but that cancel much of the statistical fluctuations for a finite Monte Carlo sample. The method is compared to what is currently the most popular method for optimizing many-body wave functions, namely minimization of the variance of the local energy. The most efficient wave function is obtained by optimizing a linear combination of the energy and the variance.Quantum Monte Carlo methods [1,2,3] are some of the most accurate and efficient methods for treating many body systems. The success of these methods is in large part due to the flexibility in the form of the trial wave functions that results from doing integrals by Monte Carlo. Since the capability to efficiently optimize the parameters in trial wave functions is crucial to the success of both the variational Monte Carlo (VMC) and the diffusion Monte Carlo (DMC) methods, a lot of effort has been put into inventing better optimization methods.The variance minimization [4,5] method has become the most frequently used method for optimizing manybody wave functions because it is far more efficient than straightforward energy minimization. The reason is that, for a sufficiently flexible variational wave function, it is possible to lower the energy on the finite set of Monte Carlo (MC) configurations on which the optimization is performed, while in fact raising the true expectation value of the energy. On the other hand, if the variance of the local energy is minimized, each term in the sum over MC configurations is bounded from below by zero and the problem is far less severe [5].Nevertheless, in recent years several clever methods have been invented that optimize the energy rather than the variance [6,7,8,9,10,11,12,13,14,15]. The motivations for this are four fold. First, one typically seeks the lowest energy in either a variational or a diffusion Monte Carlo calculation, rather than the lowest variance. Second, although the variance minimization method has been used to optimize both the Jastrow coefficients and the determinantal coefficients (the coefficients in front of the determinants, and in the expansion of the orbitals in a basis, and the exponents in the Slater/Gaussian basis functions) [5,16,17], it takes many iterations to optimize the latter and the optimization can get stuck in multiple local minima. So, most authors have used variance minimization for the Jastrow parameters only, where these problems are absent. Third, for a given form of the trial wave function, energy-minimized wave functions on average yield more accurate values of other expectation va...