Book Image

Mastering Python Scientific Computing

Book Image

Mastering Python Scientific Computing

Overview of this book

Table of Contents (17 chapters)
Mastering Python Scientific Computing
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Symbolic integrals


Methods meant for calculating definite and indefinite integrals of a given expression are implemented in the integrals module. There are two main methods in this module—one for definite integrals and other for indefinite integrals—as follows:

  • Integrate(f , x): This computes the indefinite integral of function f with respect to x (∫fdx)

  • Integrate(f, (x, m, n)): This computes the definite integral of f with respect to x in the limit m to n (∫mnfdx)

This module allows users to compute integrals on various types of functions, ranging from simple polynomials to complex exponential polynomials. The following program performs integration on a number of functions to demonstrate its capability:

from sympy import integrate, log, exp, oo
from sympy.abc import n, x, y
from sympy import sqrt
from sympy import *
integrate(x*y, x)
integrate(log(x), x)
integrate(log(x), (x, 1, n))
integrate(x)
integrate(sqrt(1 + x), (x, 0, x))
integrate(sqrt(1 + x), x)
integrate(x*y)
integrate(x**n*exp...