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

Functions for rational numbers, exponentials, and logarithms


SymPy has a number of functions for working on rational numbers. These functions perform various operations on rational numbers, including simplify, expansion, combine, split, and many more. SymPy also supports several functions for exponential and logarithmic operations. There are three logarithm functions: log (used to compute base-b logarithms), ln (used to compute natural logarithms), and log10 (used to compute base-10 logarithms). The log function expects two arguments: the variable and the base. If the base is not passed, then by default, this function will compute the natural logarithm of the variable, which is equivalent to ln. To calculate the addition of two rational numbers, we use the together function. Similarly, to divide a rational expression's numerator by a denominator, we use the apart function which is used in the following program:

from sympy import together, apart, symbols
x1, x2, x3, x4 = symbols('x1 x2 x3...