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

Calculus


Calculus involves operations that are performed to study the various properties of any function, including rates of change, the limit behavior of a function, and calculation of the area under a function graph. In this section, you will learn the concepts of limits, derivatives, summation of series, and integrals. The following program uses limit functions to solve simple limit problems:

from sympy import limit, oo, symbols,exp, cos

oo+5
67000 < oo
10/oo

x , n = symbols ('x n')
limit( ((x**n - 1)/ (x - 1) ), x, 1)

limit( 1/x**2, x, 0)
limit( 1/x, x, 0, dir="-")

limit(cos(x)/x, x, 0)
limit(sin(x)**2/x, x, 0)
limit(exp(x)/x,x,oo)

Any SymPy expression can be differentiated using the diff function with the diff(func_to_be_differentiated, variable) prototype. The following program uses the diff function to compute the differentiation of various SymPy expressions:

from sympy import diff, symbols, Symbol, exp, dsolve, subs, Function

diff(x**4, x)
diff( x**3*cos(x), x )
diff( cos(x...