  In this paper, we investigate the energy function, formation rate and
environment of fast radio bursts (FRBs) using Parkes sample and Australian
Square Kilometer Array Pathfinder (ASKAP) sample. For the first time, the
metallicity effect on the formation rate is considered. If FRBs are produced by
the mergers of compact binaries, the formation rate of FRBs should have a time
delay relative to cosmic star formation rate (CSFR). We get the time delay is
about 3-5 Gyr and the index of differential energy function $\gamma$
($dN/dE\propto E^{-\gamma}$) is between 1.6 and 2.0 from redshift cumulative
distribution. The value of $\gamma$ is similar to that of FRB 121102, which
indicates single bursts may share the same physical mechanism with the
repeaters. In another case, if the formation rate of FRB is proportional to the
SFR without time delay, the index $\gamma$ is about 2.3. In both cases, we find
that FRBs may prefer to occur in low-metallicity environment with $ 12
+\log(\rm{O/H}) \simeq 8.40$, which is similar to those of long gamma-ray
bursts (GRBs) and hydrogen-poor superluminous supernovae (SLSNe-I).
