Calculation of the characteristic functions of anharmonic oscillators