Related Articles
Python | sympy.Integral() method
• Last Updated : 02 Aug, 2019

With the help of sympy.Integral() method, we can create an unevaluated integral of a SymPy expression. It has the same syntax as integrate() method. To evaluate an unevaluated integral, use the doit() method.

Syntax: Integral(expression, reference variable)

Parameters:
expression – A SymPy expression whose unevaluated integral is found.
reference variable – Variable with respect to which integral is found.

Returns: Returns an unevaluated integral of the given expression.

Example #1:

 `# import sympy ``from` `sympy ``import` `*` ` ` `x, y ``=` `symbols(``'x y'``)``expr ``=` `x``*``*``2` `+` `2` `*` `y ``+` `y``*``*``3``print``(``"Expression : {} "``.``format``(expr))``  ` `# Use sympy.Integral() method ``expr_intg ``=` `Integral(expr, x)  ``     ` `print``(``"Integral of expression with respect to x : {}"``.``format``(expr_intg))  ``print``(``"Value of the Integral : {} "``.``format``(expr_intg.doit()))`

Output:

```Expression : x**2 + y**3 + 2*y
Integral of expression with respect to x : Integral(x**2 + y**3 + 2*y, x)
Value of the Integral : x**3/3 + x*(y**3 + 2*y)
```

Example #2:

 `# import sympy ``from` `sympy ``import` `*` ` ` `x, y ``=` `symbols(``'x y'``)``expr ``=` `y``*``*``3` `*` `x``*``*``2` `+` `2` `*` `y``*``x ``+` `x ``*` `y``*``*``3``print``(``"Expression : {} "``.``format``(expr))``  ` `# Use sympy.Integral() method ``expr_intg ``=` `Integral(expr, x, y)  ``     ` `print``(``"Integral of expression with respect to x : {}"``.``format``(expr_intg))  ``print``(``"Value of the Integral : {} "``.``format``(expr_intg.doit()))`

Output:

```Expression : x**2*y**3 + x*y**3 + 2*x*y
Integral of expression with respect to x : Integral(x**2*y**3 + x*y**3 + 2*x*y, x, y)
Value of the Integral : x**2*y**2/2 + y**4*(x**3/12 + x**2/8)
```

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up