def encrypt(public_key, msg, precision=None):
    """
    Encode and Paillier encrypt a real number *msg*.

        Args:
          msg: an int or float to be encrypted. If int, it must satisfy abs(*msg*) < public_key.n / 3.
            If float, it must satisfy abs(*msg* / *precision*) << n / 3
            (i.e. if a float is near the limit then detectable
            overflow may still occur)
          precision (float): Passed to :method:`EncodedNumber.encode`.
            If *msg* is a float then *precision* is the maximum
            **absolute** error allowed when encoding *msg*. Defaults
            to encoding *msg* exactly.

    :param public_key: public key
    :param msg: message
    :param precision: this is optional, the maximum absolute error allowed when encoding *msg*
    :return: Enc(message)
    """
    return public_key.encrypt(msg, precision)