Optimization of optical parameters and electric-field distribution in multilayers