Analytical ansatz for self-consistent calculations of x-ray transmission and reflection coefficients at graded interfaces