code: def find_simple_recurrence(v, A=Function("a"), N=Symbol("n")):
      """
      Detects and returns a recurrence relation from a sequence of several integer
      (or rational) terms. The name of the function in the returned expression is
      'a' by default; the main variable is 'n' by default. The smallest index in
      the returned expression is always n (and never n-1, n-2, etc.).
  
      Examples
      ========
  
      >>> from sympy.concrete.guess import find_simple_recurrence
      >>> from sympy import fibonacci
      >>> find_simple_recurrence([fibonacci(k) for k in range(12)])
      -a(n) - a(n + 1) + a(n + 2)
  
      >>> from sympy import Function, Symbol
      >>> a = [1, 1, 1]
      >>> for k in range(15): a.append(5*a[-1]-3*a[-2]+8*a[-3])
      >>> find_simple_recurrence(a, A=Function('f'), N=Symbol('i'))
      -8*f(i) + 3*f(i + 1) - 5*f(i + 2) + f(i + 3)
  
      """
      p = find_simple_recurrence_vector(v)
      n = len(p)
      if n <= 1:
          return S.Zero
  
      return Add(*[A(N + n - 1 - k) * p[k] for k in range(n)])
  
file_path: sympy/sympy/concrete/guess.py
imports: from sympy.concrete.products import Product, product
  from sympy.core import Function, S
  from sympy.core.add import Add
  from sympy.core.numbers import Integer, Rational
  from sympy.core.symbol import Symbol, symbols
  from sympy.core.sympify import sympify
  from sympy.functions.elementary.exponential import exp
  from sympy.functions.elementary.integers import floor
  from sympy.integrals.integrals import integrate
  from sympy.polys.polyfuncs import rational_interpolate
  from sympy.polys.polytools import lcm
  from sympy.simplify.radsimp import denom
  from sympy.utilities import public
label_desc: Use image node_id 2 for calling a global function with example usage: find_simple_recurrence(v, A, N) and returns: Add, S