Python | sympy.euler() method

With the help of sympy.euler() method, we can find the Euler number and Euler polynomial in SymPy.

euler(n) -

Syntax: euler(n)



Parameter:
n – It denotes the nth Euler number.

Returns: Returns the nth Euler number.

Example #1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# import sympy 
from sympy import * n = 4
print("Value of n = {}".format(n))
   
# Use sympy.euler() method 
nth_euler = euler(n)  
      
print("Value of nth euler number : {}".format(nth_euler))  

chevron_right


Output:

Value of n = 4
Value of nth euler number : 5

euler(n, k) -

Syntax: euler(n, k)

Parameter:
n – It denotes the order of the Euler polynomial.
k – It denotes the variable in the Euler polynomial.

Returns: Returns the expression of the Euler polynomial or its value.

Example #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# import sympy 
from sympy import * n = 5
k = symbols('x')
print("Value of n = {} and k = {}".format(n, k))
   
# Use sympy.euler() method 
nth_euler_poly = euler(n, k)  
      
print("The nth euler polynomial : {}".format(nth_euler_poly))  

chevron_right


Output:

Value of n = 5 and k = x
The nth euler polynomial : x**5 - 5*x**4/2 + 5*x**2/2 - 1/2

Example #3:

filter_none

edit
close

play_arrow

link
brightness_4
code

# import sympy 
from sympy import * n = 4
k = 3
print("Value of n = {} and k = {}".format(n, k))
   
# Use sympy.euler() method 
nth_euler_poly = euler(n, k)  
      
print("The nth euler polynomial value : {}".format(nth_euler_poly))  

chevron_right


Output:

Value of n = 4 and k = 3
The nth euler polynomial value : 30


My Personal Notes arrow_drop_up

Coder Machine Learner Social Activist Vocalist

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.