Introduction to Scientific Programming with Python

Categories:

Recommended

This book was originally written as a set of lecture notes to the book A Primer on Scientific Programming with Python by Hans Petter Langtangen, and can be used either as a supplement to that book or on its own, as a compact introduction to scientific programming. Langtangen’s book and these lecture notes, have formed the core of an introductory course on scientific programming at the University of Oslo (INF1100/IN1900, 10 ETCS credits). The course has been running since 2007 and is primarily taken by first-year students of mathematics, engineering, physics, chemistry, and geosciences.

The writing of these lecture notes, and their subsequent evolution into a book, were primarily motivated by two factors. The first was that many students found the nearly 1000 pages of Langtangen’s book a bit overwhelming as a first introduction to programming. This effect could be mostly psychological, since the book is well structured and suited for selective study of chapters and sections, but the student feedback from students still indicated the need for a more compact and (literally) lightweight introduction. The second factor was that, sadly, Hans Petter Langtangen passed away in 2016, and his book has therefore not been updated to the newest versions of Python and the various tools introduced in the book. This issue could also be mostly a mental obstacle, since the differences between the Python versions are quite small, and only minor edits are needed to make most of the examples from the original book run on the newest Python platform. However, the book is intended as an introduction to programming, and when learning an entirely new topic, any minor inconsistency is a potential source of confusion. I therefore saw the need for an updated document where all the code examples would run without any modifications on the most common Python platforms. That said, in spite of these minor shortcomings as an introductory text, Langtangen’s book is still an excellent resource on scientific programming in Python. Compared with the present book, it covers a much broader set of topics and includes more examples, more detailed discussions and explanations, and many more useful programming hints and tips. I highly recommend it as a supplement to these notes for anyone with ambitions to become an expert scientific programmer.

The present book was written specifically for the course Introduction to programming for scientific applications (IN1900) at the University of Oslo. It follows exactly the same teaching philosophy and general structure as Langtangen’s original book, with the overarching idea that the only way to learn to program is to write programs. Reading theory is useful, but without actual programming practice, the value is very limited. The IN1900 course is therefore largely based on problem solving and programming exercises, and this book’s main purpose is to prepare the students for such tasks by providing a brief introduction to fundamental programming concepts and Python tools. The presentation style is compact and pragmatic, and includes a large number of code examples to illustrate how new concepts work and are applied in practice. The examples are a combination of pieces of code (so-called code snippets), complete Python programs, and interactive sessions in a Python shell. Readers are encouraged to run and modify the codes to gain a feel for how the various programming concepts work. Source code for most of the examples, as well as Jupyter notebooks for all the chapters, is provided in the online resources accompanying this book.

The typical reader of the book will be a student of mathematics, physics, chemistry, or other natural science, and many of the examples will be familiar to these readers. However, the rapidly increasing relevance of data science means that computations and scientific programming will be of interest to a growing group of users. No typical data science tools are presented in this book, but the reader will learn tasks such as reading data from files, simple text processing, and programming with mathematics and floating point computations. These are all fundamental building blocks of any data science application, and they are essential to know before diving into more advanced and specialized tools.

No prior knowledge of programming is needed to read this book. We start with some very simple examples to get started with programming and then move on to introduce fundamental programming concepts such as loops, functions, if-tests, lists, and classes. These generic concepts are supplemented by more specific and practical tools for scientific programming, primarily plotting and array-based computations. The book’s overall purpose is to introduce the reader to programming and, in particular, to demonstrate how programming can be an extremely useful and powerful tool in many branches of the natural sciences.

Many people have contributed to this book, in particular my colleagues at Simula Research Laboratory and the University of Oslo. However, the contributions of Professor Hans Petter Langtangen stand head and shoulders above everyone else. He has been an extremely inspiring teacher, mentor, and colleague throughout my scientific career; he developed the course that is now IN1900; and he wrote the book on which these notes are based. Throughout these lecture notes I have extensively copied ideas, presentation style, and code examples from his original book, simply because I find them excellent for introducing programming in a scientific context. If it were not for Hans Petter I would clearly never have written these notes. I would probably not be writing this either if he had not, sadly, passed away in 2016 – there would be no need to, because he would surely have written a far better and more extensive book himself.

Category:

Attribution

Joakim Sundnes. Introduction to Scientific Programming with Pythonhttps://library.oapen.org/bitstream/id/56d27e73-e92a-4398-8198-239be7aacc93/2020_Book_IntroductionToScientificProgra.pdf

VP Flipbook Maker

Convert your work to digital flipbook with VP Online Flipbook Maker! You can also create a new one with the tool. Try it now!