(self, func)
Given the suitable target ``func``, try to find an origin in our
        knowledge base.

        >>> from sympy.simplify.hyperexpand import (FormulaCollection,
        ...     Hyper_Function)
        >>> f = FormulaCollection()
        >>> f.lookup_origin(Hyper_Function((), ())).closed_form
        exp(_z)
        >>> f.lookup_origin(Hyper_Function([1], ())).closed_form
        HyperRep_power1(-1, _z)

        >>> from sympy import S
        >>> i = Hyper_Function([S('1/4'), S('3/4 + 4')], [S.Half])
        >>> f.lookup_origin(i).closed_form
        HyperRep_sqrts1(-1/4, _z)
Given the suitable target ``func``, try to find an origin in our
        knowledge base.
Given the suitable target func try to find an origin in our knowledge base .
def lookup_origin(self, func):
        """
        Given the suitable target ``func``, try to find an origin in our
        knowledge base.

        >>> from sympy.simplify.hyperexpand import (FormulaCollection,
        ...     Hyper_Function)
        >>> f = FormulaCollection()
        >>> f.lookup_origin(Hyper_Function((), ())).closed_form
        exp(_z)
        >>> f.lookup_origin(Hyper_Function([1], ())).closed_form
        HyperRep_power1(-1, _z)

        >>> from sympy import S
        >>> i = Hyper_Function([S('1/4'), S('3/4 + 4')], [S.Half])
        >>> f.lookup_origin(i).closed_form
        HyperRep_sqrts1(-1/4, _z)
        """
        inv = func.build_invariants()
        sizes = func.sizes
        if sizes in self.concrete_formulae and \
                inv in self.concrete_formulae[sizes]:
            return self.concrete_formulae[sizes][inv]

        # We don't have a concrete formula. Try to instantiate.
        if not sizes in self.symbolic_formulae:
            return None  # Too bad...

        possible = []
        for f in self.symbolic_formulae[sizes]:
            repls = f.find_instantiations(func)
            for repl in repls:
                func2 = f.func.xreplace(repl)
                if not func2._is_suitable_origin():
                    continue
                diff = func2.difficulty(func)
                if diff == -1:
                    continue
                possible.append((diff, repl, f, func2))

        # find the nearest origin
        possible.sort(key=lambda x: x[0])
        for _, repl, f, func2 in possible:
            f2 = Formula(func2, f.z, None, [], f.B.subs(repl),
                    f.C.subs(repl), f.M.subs(repl))
            if not any(e.has(S.NaN, oo, -oo, zoo) for e in [f2.B, f2.M, f2.C]):
                return f2
        else:
            return None
def lookup_origin ( self , func ) : inv = func . build_invariants ( ) sizes = func . sizes if sizes in self . concrete_formulae and inv in self . concrete_formulae [ sizes ] : return self . concrete_formulae [ sizes ] [ inv ] # We don't have a concrete formula. Try to instantiate. if not sizes in self . symbolic_formulae : return None # Too bad... possible = [ ] for f in self . symbolic_formulae [ sizes ] : repls = f . find_instantiations ( func ) for repl in repls : func2 = f . func . xreplace ( repl ) if not func2 . _is_suitable_origin ( ) : continue diff = func2 . difficulty ( func ) if diff == - 1 : continue possible . append ( ( diff , repl , f , func2 ) ) # find the nearest origin possible . sort ( key = lambda x : x [ 0 ] ) for _ , repl , f , func2 in possible : f2 = Formula ( func2 , f . z , None , [ ] , f . B . subs ( repl ) , f . C . subs ( repl ) , f . M . subs ( repl ) ) if not any ( e . has ( S . NaN , oo , - oo , zoo ) for e in [ f2 . B , f2 . M , f2 . C ] ) : return f2 else : return None