p4c_Python.pdf
(
4503 KB
)
Pobierz
Programming for Computations
- A Gentle Introduction to
Numerical Simulations with
Python
Svein Linge
1,2
Hans Petter Langtangen
2,3
1
Department of Process, Energy and Environmental Technology,
University College of Southeast Norway
Center for Biomedical Computing, Simula Research Laboratory
3
2
Department of Informatics, University of Oslo
iv
This text teaches computer programming as a method for solving
mathematical problems. There are two versions of this book, one
for the MATLAB and one for Python. While it was inspired by
the Springer text TCSE6: A Primer on Scientific Programming
with Python (by Langtangen), its exposition is more accessible,
simpler, and much shorter and aimed at engineering students. The
authors have outlined the shortest possible path from zero knowledge
about programming to a set of skills that will allow the students in
engineering and science courses to write simple programs for solving
common mathematical problems by numerical methods. This text
places great emphasis on generic algorithms, clean program designs,
function use, and automatic tests for verification.
Feb 29, 2016
Preface
Computing, in the sense of doing mathematical calculations, is a skill
that mankind has developed over thousands of years. Programming,
on the other hand, is in its infancy, with a history that spans a few
decades only. Both topics are vastly comprehensive and usually taught as
separate subjects in educational institutions around the world, especially
at the undergraduate level. This book is about the
combination
of the
two, because computing today becomes so much more powerful when
combined with programming.
Most universities and colleges implicitly require students to specialize
in computer science if they want to learn the craft of programming, since
other student programs usually do not offer programming to an extent
demanded for really mastering this craft. Common arguments claim that
it is sufficient with a brief introduction, that there is not enough room for
learning programming in addition to all other must-have subjects, and
that there is so much software available that few really need to program
themselves. A consequence is that engineering students often graduate
with shallow knowledge about programming, unless they happened to
choose the computer science direction.
We think this is an unfortunate situation. There is no doubt that
practicing engineers and scientists need to know their pen and paper
mathematics. They must also be able to run off-the-shelf software for
important standard tasks and will certainly do that a lot. Nevertheless,
the benefits of mastering programming are many.
Why learn programming?
v
vi
1. Ready-made software is limited to handling certain standard problems.
What do you do when the problem at hand is not covered by the
software you bought? Fortunately, a lot of modern software systems
are extensible via programming. In fact, many systems demand parts
of the problem specification (e.g., material models) to be specified by
computer code.
2. With programming skills, you may extend the flexibility of existing
software packages by combining them. For example, you may integrate
packages that do not speak to each other from the outset. This makes
the work flow simpler, more efficient, and more reliable, and it puts
you in position to attack new problems.
3. It is easy to use excellent ready-made software the wrong way. Insight
in programming and the mathematics behind is fundamental for
understanding complex software, avoiding pitfalls, and become a safe
user.
4. Bugs (errors in computer code) are present in most larger computer
programs (also in the ones from the shop!). What do you do when
your ready-made software gives unexpected results? Is it a bug, is
it wrong use, or is it the mathematically correct result? Experience
with programming of mathematics gives you a good background for
answering these questions. The one who can program, can also make
tailored code for a simplified problem setting and use that to verify
the computations done with off-the-shelf software.
5. Lots of skilled people around the world solve computational problems
by writing their own code and offer their code for free on the Internet.
To take advantage of this truly great source of software in a reliable
way, one must normally be able to understand and possibly modify
computer code offered by others.
6. It is recognized world wide that students struggle with mathematics
and physics. Too many find such subjects difficult and boring. With
programming, we can execute the good old subjects in a brand new
way! According to the authors’ own experience, students find it much
more motivating and enlightening when programming is made an inte-
grated part of mathematics and physical science courses. In particular,
the problem being solved can be much more realistic than when the
mathematics is restricted to what you can do with pen and paper.
7. Finally, we launch our most important argument for learning com-
puter programming: the
algorithmic thinking
that comes with the
process of writing a program for a computational problem enforces a
thorough understanding of both the problem and solution method. We
vii
can simply quote the famous Norwegian computer scientist Kristen
Nyggaard: “Programming is understanding”.
In the authors’ experience, programming is an excellent pedagogical tool
for understanding mathematics: “You think you know when you can
learn, are more sure when you can write, even more when you can teach,
but certain when you can program” (Alan Perlis, computer scientist,
1922-1990). Consider, for example, integration. A numerical method for
integration has a much stronger focus on what the integral actually is
and means compared to analytical methods, where much time and effort
must be devoted to integration by parts, integration by substitution,
etc. Moreover, when programming the numerical integration formula, it
becomes evident that it works for “all” mathematical functions and that
the implementation should be in terms of a
general
function applicable to
“all” integrals. In this way, students learn to recognize a special problem as
belonging to a class of problems (e.g., integration, differential equations,
root finding), for which we have general numerical methods implemented
in widely applicable software. When they write this software, as we do
in this book, they learn how to generalize and increase the abstraction
level of the mathematical problem. When they use this software, they
learn how a special case should be attacked by general methods and
software for the class of problems that comprises the special case at hand.
This is the power of mathematics in a nutshell, and it is paramount that
students understand this way of thinking.
Target audience and background knowledge.
This book was writ-
ten for students, teachers, engineers and scientists that know
nothing
about programming and numerical methods from before, but who seek
a
minimum
of the fundamental skills required to get started with pro-
gramming as a tool for solving scientific and engineering problems. Some
knowledge of one- and multi-variable calculus is assumed. The basic
programming concepts are presented in only 50 pages (Chapters 1 and
2), before practical applications of these concepts are demonstrated in
important mathematical subjects addressed in the remaining parts of the
book (Chapters 3-6). Each chapter is followed by a set of exercises that
cover a wide range of application areas, e.g. biology, geology, statistics,
physics and mathematics. The exercises were particularly designed to
bring across important points from the text. The reader will realize that
the modest content of the first 50 pages can in fact bring you quite far
in powerful problem solving!
Plik z chomika:
swepper
Inne pliki z tego folderu:
Beginning Python Visualization, 2nd Edition_.pdf
(6716 KB)
Beginning Python, 3rd Edition_.pdf
(6042 KB)
Beginning Python - Using Python 2.6 and Python 3.1 (2010).pdf
(4522 KB)
dokumen.pub_practical-machine-learning-for-data-analysis-using-python-1nbsped-0128213795-9780128213797.pdf
(6414 KB)
dokumen.pub_clean-python-elegant-coding-in-python-978-1-4842-4877-5-978-1-4842-4878-2.pdf
(2209 KB)
Inne foldery tego chomika:
10 Raspberry Pi Book Collection Set - 1 ( Project, Tricks, Hacks and Fixes )
20 Engineering Books Collection
20 For Dummies Series Books Collection Pack-15
Activity Coefficients In Electrolyte Solutions Pitzer Book
Ansys Tutorials
Zgłoś jeśli
naruszono regulamin