def gamma_PML(x, gamma, PML_start, PML_thk):
    """
    Polynomial stretching profile for a perfectly matched layer.

    Parameters:
        x : physical coordinate
        gamma : average value of the profile
        PML_start : where the PML starts
        PML_thk : thickness of the PML

    Returns:
        the value of the profile function at x
    """
    return 1 + 3*(gamma - 1)*((abs(x - PML_start))/PML_thk)**2