Con la ayuda del método sympy.bell() , podemos encontrar el número de Bell y los polinomios de Bell en SymPy.
campana(n) –
Sintaxis: campana(n)
Parámetro:
n – Denota el orden del número de campana.Devoluciones: Devuelve el n -ésimo número de campana.
Ejemplo 1:
# import sympy from sympy import * n = 5 print("Value of n = {}".format(n)) # Use sympy.bell() method nth_bell = bell(n) print("Value of nth bell number : {}".format(nth_bell))
Producción:
Value of n = 5 Value of nth bell number : 52
campana (n, k) –
Sintaxis: campana(n, k)
Parámetro:
n – Denota el orden del polinomio de la campana.
k – Denota la variable en el polinomio de campana.Devuelve: Devuelve la expresión del polinomio de campana o su valor.
Ejemplo #2:
# import sympy from sympy import * n = 5 k = symbols('x') print("Value of n = {} and k = {}".format(n, k)) # Use sympy.bell() method nth_bell_poly = bell(n, k) print("The nth bell polynomial : {}".format(nth_bell_poly))
Producción:
Value of n = 5 and k = x The nth bell polynomial : x**5 + 10*x**4 + 25*x**3 + 15*x**2 + x
Ejemplo #3:
# import sympy from sympy import * n = 5 k = 3 print("Value of n = {} and k = {}".format(n, k)) # Use sympy.bell() method nth_bell_poly = bell(n, k) print("The nth bell polynomial value : {}".format(nth_bell_poly))
Producción:
Value of n = 5 and k = 3 The nth bell polynomial value : 1866
campana(n, k, (x1, x2, x3, …)) –
Sintaxis: campana(n, k, (x1, x2, x3, …))
Parámetro:
n – Denota el orden del polinomio de campana de segundo tipo.
k – Es un parámetro en el polinomio de campana de segundo tipo.
(x1, x2, x3, …) – Denota la tupla de símbolos variables.Devuelve: Devuelve los polinomios de Bell del segundo tipo.
Ejemplo #4:
# import sympy from sympy import * n = 5 k = 3 variables = symbols('x:6')[1:] print("Value of n = {}, k = {} and variables = {}".format(n, k, variables)) # Use sympy.bell() method nth_bell_poly = bell(n, k, variables) print("The nth bell polynomial of second kind : {}".format(nth_bell_poly))
Producción:
Value of n = 5, k = 3 and variables = (x1, x2, x3, x4, x5) The nth bell polynomial of second kind : 10*x1**2*x3 + 15*x1*x2**2
Publicación traducida automáticamente
Artículo escrito por rupesh_rao y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA