def inverse_generator(y):
    """ Return the inverse generator of a given generator of a rational function field.

    INPUT:

    - ``y`` - a generator of a rational function field `F=K(x)`

    OUTPUT: the inverse generator for `y`. So if `\\phi:F\\to F` is the automorphism
    of `F` such that `\\phi(x)=y` then `z:=\\phi^{-1}(x)` is the inverse generator.

    """
    from sage.matrix.constructor import matrix
    F = y.parent()
    x = F.gen()
    K = F.constant_field()
    num = y.numerator()
    denom = y.denominator()
    A = matrix(K, 2, 2, [num[1], num[0], denom[1], denom[0]])
    assert A.is_invertible(), 'y is not a generator!'
    B = A.inverse()
    z = (B[0, 0] * x + B[0, 1]) / (B[1, 0] * x + B[1, 1])
    assert F.hom(y)(z) == x
    return z
