Python | sympy.Integral() method
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**3print("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**3print("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)
Recommended Posts:
- class method vs static method in Python
- Python | os.dup() method
- Python | set() method
- Python | next() method
- Python | os.waitid() method
- Python | shutil.which() method
- Python PIL | getpalette() Method
- Python PIL | getcolors() Method
- Python | os.WIFEXITED() method
- Python | Tensorflow cos() method
- Python | os.major() method
- Python | os.stat() method
- Python | os.minor() method
- Python | os.fstat() method
- Python | os.umask() method
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.



