Python | sympy.integrate () с использованием ограничений

Опубликовано: 12 Апреля, 2022

With the help of sympy.integrate(expression, limit) method, we can find the integration of mathematical expressions using limits in the form of variables by using sympy.integrate(expression, limit) method.

Syntax : sympy.integrate(expression, reference variable, limit)
Return : Return integration of mathematical expression.

Пример №1:

In this example we can see that by using sympy.integrate(expression, limits) method, we can find the integration of mathematical expression using limits with variables. Here we use symbols() method also to declare a variable as symbol.

# import sympy
from sympy import * 
  
x, y = symbols("x y")
gfg_exp = cos(x)
  
print("Before Integration : {}".format(gfg_exp))
  
# Use sympy.integrate() method
intr = integrate(gfg_exp,  (x, -oo, oo))
  
print("After Integration : {}".format(intr))

Output :

Before Integration : cos(x)

After Integration : AccumBounds(-2, 2)

 
Example #2 :

# import sympy
from sympy import * 
  
x, y = symbols("x y")
gfg_exp = tan(x)
  
print("Before Integration : {}".format(gfg_exp))
  
# Use sympy.integrate() method
intr = integrate(gfg_exp,  (x, -1, 1))
  
print("After Integration : {}".format(intr))

Output :

Before Integration : tan(x)

After Integration : 0

Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.

Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.