A real-space method is developed to calculate molecular hyperpolarizabiliti
es in the time-dependent density functional theory. The method is based on
the response function formalism which was developed by Senatore and Subbasw
amy for the third harmonic generation of rare-gas atoms [Phys. Rev. A 35, 2
440 (1987)]. The response equations are discretized in real space employing
a uniform grid representation in the three-dimensional Cartesian coordinat
e, and are solved with iterative methods such as conjugate-gradient and con
jugate-residual methods. The method works efficiently for both small and la
rge molecules, and for any nonlinear optical processes up to third order. T
he spatial convergence of the calculation can be examined with two intuitiv
e parameters, the grid spacing and the spatial box size. Applications of ou
r method are presented for rare-gas atoms and molecules, N-2, H2O, C2H4, C6
H6, and C-60. Our results agree well with other calculations employing basi
s functions except for a slight deviation in a large molecule, C-60. (C) 20
01 American Institute of Physics.