Programming for Computations - Python

A Gentle Introduction to Numerical Simulations with Python 3.6

by Svein Linge, Hans Petter Langtangen

DescriptionTable of ContentsDetailsHashtagsReport an issue

Book Description

This book presents computer programming as a key method for solving mathematical problems. This second edition of the well-received book has been extensively revised: All code is now written in Python version 3.6 (no longer version 2.7). In addition, the two first chapters of the previous edition have been extended and split up into five new chapters, thus expanding the introduction to programming from 50 to 150 pages. Throughout the book, the explanations provided are now more detailed, previous examples have been modified, and new sections, examples and exercises have been added. Also, a number of small errors have been corrected.

The book was inspired by the Springer book TCSE 6: A Primer on Scientific Programming with Python (by Langtangen), but the style employed is more accessible and concise, in keeping with the needs of engineering students.

The book outlines the shortest possible path from no previous experience with programming to a set of skills that allows students to write simple programs for solving common mathematical problems with numerical methods in the context of engineering and science courses. The emphasis is on generic algorithms, clean program design, the use of functions, and automatic tests for verification.

This open book is licensed under a Creative Commons License (CC BY). You can download Programming for Computations - Python ebook for free in PDF format (7.3 MB).

Table of Contents

Chapter 1
The First Few Steps
 
 
1.1 What Is a Program? And What Is Programming?
 
 
1.2 A Python Program with Variables
 
 
1.3 A Python Program with a Library Function
 
 
1.4 Importing from Modules and Packages
 
 
1.5 A Python Program with Vectorization and Plotting
 
 
1.6 Plotting, Printing and Input Data
 
 
1.7 Error Messages and Warnings
 
 
1.8 Concluding Remarks
 
 
1.9 Exercises
 
Chapter 2
A Few More Steps
 
 
2.1 Using Python Interactively
 
 
2.2 Variables, Objects and Expressions
 
 
2.3 Numerical Python Arrays
 
 
2.4 Random Numbers
 
 
2.5 Exercises
 
Chapter 3
Loops and Branching
 
 
3.1 The for Loop
 
 
3.2 The while Loop
 
 
3.3 Branching (if, elif and else)
 
 
3.4 Exercises
 
Chapter 4
Functions and the Writing of Code
 
 
4.1 Functions: How to Write Them?
 
 
4.2 Programming as a Step-Wise Strategy
 
 
4.3 Exercises
 
Chapter 5
Some More Python Essentials
 
 
5.1 Lists and Tuples: Alternatives to Arrays
 
 
5.2 Exception Handling
 
 
5.3 Symbolic Computations
 
 
5.4 Making Our Own Module
 
 
5.5 Files: Read and Write
 
 
5.6 Measuring Execution Time
 
 
5.7 Exercises
 
Chapter 6
Computing Integrals and Testing Code
 
 
6.1 Basic Ideas of Numerical Integration
 
 
6.2 The Composite Trapezoidal Rule
 
 
6.3 The Composite Midpoint Method
 
 
6.4 Vectorizing the Functions
 
 
6.5 Rate of Convergence
 
 
6.6 Testing Code
 
 
6.7 Double and Triple Integrals
 
 
6.8 Exercises
 
Chapter 7
Solving Nonlinear Algebraic Equations
 
 
7.1 Brute Force Methods
 
 
7.2 Newton's Method
 
 
7.3 The Secant Method
 
 
7.4 The Bisection Method
 
 
7.5 Rate of Convergence
 
 
7.6 Solving Multiple Nonlinear Algebraic Equations
 
 
7.7 Exercises
 
Chapter 8
Solving Ordinary Differential Equations
 
 
8.1 Filling a Water Tank: Two Cases
 
 
8.2 Population Growth: A First Order ODE
 
 
8.3 Spreading of Disease: A System of First Order ODEs
 
 
8.4 Oscillating 1D Systems: A Second Order ODE
 
 
8.5 Rate of Convergence
 
 
8.6 Exercises
 
Chapter 9
Solving Partial Differential Equations
 
 
9.1 Example: Temperature Development in a Rod
 
 
9.2 Finite Difference Methods
 
 
9.3 Exercises
 

Book Details

Subject
Computer Science
Publisher
Springer
Published
2020
Pages
350
Edition
2
Language
English
ISBN13
9783030168766
ISBN10
303016876X
ISBN13 Digital
9783030168773
ISBN10 Digital
3030168778
PDF Size
7.3 MB
License
CC BY

Related Books

Programming for Computations - Python
This book presents computer programming as a key method for solving mathematical problems. There are two versions of the book, one for MATLAB and one for Python. The book was inspired by the Springer book TCSE 6: A Primer on Scientific Programming with Python (by Langtangen), but the style is more accessible and concise, in keeping with the needs o...
Programming for Computations - MATLAB/Octave
This book presents computer programming as a key method for solving mathematical problems. There are two versions of the book, one for MATLAB and one for Python. The book was inspired by the Springer book TCSE 6: A Primer on Scientific Programming with Python (by Langtangen), but the style is more accessible and concise, in keeping with the needs o...
Programming Persistent Memory
Beginning and experienced programmers will use this comprehensive guide to persistent memory programming. You will understand how persistent memory brings together several new software/hardware requirements, and offers great promise for better performance and faster application startup times - a huge leap forward in byte-addressable capacity compar...
A Byte of Python
Python is one of those rare languages which can claim to be both simple and powerful. You will find yourself pleasantly surprised to see how easy it is to concentrate on the solution to the problem rather than the syntax and structure of the language you are programming in. A Byte of Python is a free book on programming using the Python language...
Analysis for Computer Scientists
This easy-to-follow textbook/reference presents a concise introduction to mathematical analysis from an algorithmic point of view, with a particular focus on applications of analysis and aspects of mathematical modelling. The text describes the mathematical theory alongside the basic concepts and methods of numerical analysis, enriched by computer ...
Scaling of Differential Equations
The book serves both as a reference for various scaled models with corresponding dimensionless numbers, and as a resource for learning the art of scaling. A special feature of the book is the emphasis on how to create software for scaled models, based on existing software for unscaled models. Scaling (or non-dimensionalization) is a mathematical...