def _reldiff2(dref, dtarget, ddref):
    """
    Convenience function for implementation of the following functions.
    The arguments `dref` and `dtarget` maybe scalars or arrays.
    The calling code is responsible for avoiding division by zero (make sure that ddref>0).
    """
    ddiff = dtarget - dref
    reldd2 = (ddiff / ddref) ** 2
    return reldd2
