bernstein_coefficients: optionally optimize during recursive computation