Piezoelectric relaxation in ferroelectrics and polymers