def gradient(self):
        r"""Gradient of the KL functional.

        The gradient of `KullbackLeibler` with ``prior`` :math:`g` is given
        as

        .. math::
            \nabla F(x) = 1 - \frac{g}{x}.

        The gradient is not defined in points where one or more components
        are non-positive.
        """
        functional = self

        class KLGradient(Operator):

            """The gradient operator of this functional."""

            def __init__(self):
                """Initialize a new instance."""
                super(KLGradient, self).__init__(
                    functional.domain, functional.domain, linear=False)

            def _call(self, x):
                """Apply the gradient operator to the given point.

                The gradient is not defined in points where one or more
                components are non-positive.
                """
                if functional.prior is None:
                    return (-1.0) / x + 1
                else:
                    return (-functional.prior) / x + 1

        return KLGradient()
r"""Gradient of the KL functional.

        The gradient of `KullbackLeibler` with ``prior`` :math:`g` is given
        as

        .. math::
            \nabla F(x) = 1 - \frac{g}{x}.

        The gradient is not defined in points where one or more components
        are non-positive.