The production rate of compact objects, i.e., neutron stars (NSs) and black holes (BHs), in active galactic nuclei (AGNs) and quasars (QSOs), where frequent supernova explosions are used to explain the high metallicity, is very high because of the interaction between the accretion disk and main-sequence stars in the nucleus of the quasar. The compact object red giant (RG) star binaries can be easily formed because of the large captured cross section of the RG stars. The (NS/BH, NS/BH) binary can be formed after the supernova explosion of the (NS/BH, RG) binary. Intense transient gamma-ray emission (gamma-ray burst) and gravitational radiation can result from the merger of these two compact objects. Collision between the helium core (Hc) of the RG and the BH may also take place and may also result in long-duration gamma-ray bursts but no gravitational waves. We estimate that the merger rate of (NS/BH, NS/BH) binaries and (Hc, BH) is proportional to the metal abundance N V/C IV and can be as high as 10~3 [(N V/C IV)/0.01] yr~1 per AGN/QSO.