
Applying Math with Python: Over 70 practical recipes for solving real-world computational math problems, 2nd Edition
- Length: 376 pages
- Edition: 2
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2022-12-09
- ISBN-10: 1804618373
- ISBN-13: 9781804618370
- Sales Rank: #0 (See Top 100 Books)
Discover easy-to-follow solutions and techniques to help you to implement applied mathematical concepts such as probability, calculus, and equations using Python’s numeric and scientific libraries
Key Features
- Compute complex mathematical problems using programming logic with the help of step-by-step recipes
- Learn how to use Python libraries for computation, mathematical modeling, and statistics
- Discover simple yet effective techniques for solving mathematical equations and apply them in real-world statistics
Book Description
The updated edition of Applying Math with Python will help you solve complex problems in a wide variety of mathematical fields in simple and efficient ways. Old recipes have been revised for new libraries and several recipes have been added to demonstrate new tools such as JAX.
You’ll start by refreshing your knowledge of several core mathematical fields and learn about packages covered in Python’s scientific stack, including NumPy, SciPy, and Matplotlib. As you progress, you’ll gradually get to grips with more advanced topics of calculus, probability, and networks (graph theory). Once you’ve developed a solid base in these topics, you’ll have the confidence to set out on math adventures with Python as you explore Python’s applications in data science and statistics, forecasting, geometry, and optimization. The final chapters will take you through a collection of miscellaneous problems, including working with specific data formats and accelerating code.
By the end of this book, you’ll have an arsenal of practical coding solutions that can be used and modified to solve a wide range of practical problems in computational mathematics and data science.
What you will learn
- Become familiar with basic Python packages, tools, and libraries for solving mathematical problems
- Explore real-world applications of mathematics to reduce a problem in optimization
- Understand the core concepts of applied mathematics and their application in computer science
- Find out how to choose the most suitable package, tool, or technique to solve a problem
- Implement basic mathematical plotting, change plot styles, and add labels to plots using Matplotlib
- Get to grips with probability theory with the Bayesian inference and Markov Chain Monte Carlo (MCMC) methods
Who this book is for
Whether you are a professional programmer or a student looking to solve mathematical problems computationally using Python, this is the book for you. Advanced mathematics proficiency is not a prerequisite, but basic knowledge of mathematics will help you to get the most out of this Python math book. Familiarity with the concepts of data structures in Python is assumed.
Cover Title Page Copyright Dedication Contributors Table of Contents Preface Chapter 1: An Introduction to Basic Packages, Functions, and Concepts Technical requirements Exploring Python numerical types Decimal type Fraction type Complex type Understanding basic mathematical functions Diving into the world of NumPy Element access Array arithmetic and functions Useful array creation routines Higher-dimensional arrays Working with matrices and linear algebra Basic methods and properties Matrix multiplication Determinants and inverses Systems of equations Eigenvalues and eigenvectors Sparse matrices Summary Further reading Chapter 2: Mathematical Plotting with Matplotlib Technical requirements Basic plotting with Matplotlib Getting ready How to do it... How it works… There’s more… Adding subplots Getting ready How to do it... How it works... There’s more... See also Plotting with error bars Getting ready How to do it… How it works… There’s more... Saving Matplotlib figures Getting ready How to do it... How it works... There’s more... See also Surface and contour plots Getting ready How to do it... How it works... There’s more... See also Customizing three-dimensional plots Getting ready How to do it... How it works... There’s more... Plotting vector fields with quiver plots Getting ready How to do it… How it works… There’s more… Further reading Chapter 3: Calculus and Differential Equations Technical requirements Primer on calculus Working with polynomials and calculus Getting ready How to do it... How it works... There’s more... See also Differentiating and integrating symbolically using SymPy Getting ready How to do it... How it works... There’s more... Solving equations Getting ready How to do it... How it works... There’s more... Integrating functions numerically using SciPy Getting ready How to do it... How it works... There’s more... Solving simple differential equations numerically Getting ready How to do it... How it works... There’s more... See also Solving systems of differential equations Getting ready How to do it... How it works... There’s more... Solving partial differential equations numerically Getting ready How to do it... How it works... There’s more... See also Using discrete Fourier transforms for signal processing Getting ready How to do it... How it works... There’s more... See also Automatic differentiation and calculus using JAX Getting ready How to do it… How it works… There’s more… See also Solving differential equations using JAX Getting ready How to do it… How it works… See also Further reading Chapter 4: Working with Randomness and Probability Technical requirements Selecting items at random Getting ready How to do it... How it works... There’s more... Generating random data Getting ready How to do it... How it works... There’s more... Changing the random number generator Getting ready How to do it... How it works... There’s more... Generating normally distributed random numbers Getting ready How to do it... How it works... There’s more... Working with random processes Getting ready How to do it... How it works... There’s more... Analyzing conversion rates with Bayesian techniques Getting ready How to do it... How it works... There’s more... Estimating parameters with Monte Carlo simulations Getting ready How to do it... How it works... There’s more... See also Further reading Chapter 5: Working with Trees and Networks Technical requirements Creating networks in Python Getting ready How to do it... How it works... There’s more... Visualizing networks Getting ready How to do it... How it works... There’s more... Getting the basic characteristics of networks Getting ready How to do it... How it works... There’s more... Generating the adjacency matrix for a network Getting ready How to do it... How it works... There’s more... Creating directed and weighted networks Getting ready How to do it... How it works... There’s more... Finding the shortest paths in a network Getting ready How to do it... How it works... There’s more... Quantifying clustering in a network Getting ready How to do it... How it works... There’s more... Coloring a network Getting ready How to do it... How it works... There’s more... Finding minimal spanning trees and dominating sets Getting ready How to do it... How it works... Further reading Chapter 6: Working with Data and Statistics What is statistics? Technical requirements Creating Series and DataFrame objects Getting ready How to do it... How it works... There’s more... See also Loading and storing data from a DataFrame Getting ready How to do it... How it works... See also Manipulating data in DataFrames Getting ready How to do it... How it works... There’s more... Plotting data from a DataFrame Getting ready How to do it... How it works... There’s more... Getting descriptive statistics from a DataFrame Getting ready How to do it... How it works... There’s more... Understanding a population using sampling Getting ready How to do it... How it works... See also Performing operations on grouped data in a DataFrame Getting ready How to do it... How it works... Testing hypotheses using t-tests Getting ready How to do it... How it works... There’s more... Testing hypotheses using ANOVA Getting ready How to do it... How it works... There’s more... Testing hypotheses for non-parametric data Getting ready How to do it... How it works... Creating interactive plots with Bokeh Getting ready How to do it... How it works... There’s more... Further reading Chapter 7: Using Regression and Forecasting Technical requirements Getting ready How to do it... How it works... There’s more... Using multilinear regression Getting ready How to do it... How it works... Classifying using logarithmic regression Getting ready How to do it... How it works... There’s more... Modeling time series data with ARMA Getting ready How to do it... How it works... There’s more... Forecasting from time series data using ARIMA Getting ready How to do it... How it works... Forecasting seasonal data using ARIMA Getting ready How to do it... How it works... There’s more... Using Prophet to model time series data Getting ready How to do it... How it works... There’s more... Using signatures to summarize time series data Getting ready How to do it… How it works… There’s more… See also Further reading Chapter 8: Geometric Problems Technical requirements Visualizing two-dimensional geometric shapes Getting ready How to do it... How it works... There’s more... See also Finding interior points Getting ready How to do it... How it works... Finding edges in an image Getting ready How to do it… How it works... Triangulating planar figures Getting ready How to do it... How it works... There’s more... See also Computing convex hulls Getting ready How to do it... How it works... Constructing Bezier curves Getting ready How to do it... How it works... There’s more... Further reading Chapter 9: Finding Optimal Solutions Technical requirements Minimizing a simple linear function Getting ready How to do it... How it works... There’s more... Minimizing a non-linear function Getting ready How to do it... How it works... There’s more... Using gradient descent methods in optimization Getting ready How to do it... How it works... There’s more... Using least squares to fit a curve to data Getting ready How to do it... How it works... There’s more... Analyzing simple two-player games Getting ready How to do it... How it works... There’s more... Computing Nash equilibria Getting ready How to do it... How it works... There’s more... See also Further reading Chapter 10: Improving Your Productivity Technical requirements Keeping track of units with Pint Getting ready How to do it... How it works... There’s more... Accounting for uncertainty in calculations Getting ready How to do it... How it works... There’s more... Loading and storing data from NetCDF files Getting ready How to do it... How it works... There’s more... Working with geographical data Getting ready How to do it... How it works... Executing a Jupyter notebook as a script Getting ready How to do it... How it works... There’s more... Validating data Getting ready How to do it... How it works... Accelerating code with Cython Getting ready How to do it... How it works... There’s more... Distributing computing with Dask Getting ready How to do it... How it works... There’s more... Writing reproducible code for data science Getting ready How to do it… How it works… There’s more… See also... Index About Packt Other Books You May Enjoy
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Applying Math with Python: Over 70 practical recipes for solving real-world computational math problems, 2nd Edition
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.