Page - 131 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Image of the Page - 131 -
Text of the Page - 131 -
6ComputingIntegralsandTestingCode
We now turn our prime attention to the solving of mathematical problems through
computer programming. A fundamentally important part of programming, is to
checkthat thewrittencodeworksas intended.That is, thecodemustbe tested.This
far, we have checked our coding in rather simple ways, e.g., by comparing to hand
calculations. Now, we will look at more powerful test strategies, while addressing
numericalcomputationof integrals.
Therearemanyreasons tochoose integrationasourfirst application. Integration
is well known already from high school mathematics. Most integrals are not
tractablebypenandpaper,andacomputerizedsolutionapproachisbothverymuch
simplerandmuchmorepowerful—youcanessentially treatall integrals ∫b
a f(x)dx
in10 linesofcomputercode!
Integration also demonstrates the difference between exact mathematics by pen
and paper and numerical mathematics on a computer. The latter approaches the
resultof theformerwithoutanyworriesaboutroundingerrorsduetofiniteprecision
arithmetics incomputers(incontrast todifferentiation,wheresucherrorspreventus
fromgettinga result as accurateaswe desire).
Finally, integration is thought of as a somewhat difficult mathematical concept
tograsp,andprogrammingintegrationshouldgreatly improvetheunderstandingof
what integrationreally isandhowit works.
Not onlyshall we understandhow to use the computer to integrate,but we shall
also learn a series of good habits to ensure your computer work is of the highest
scientific quality. In particular,we will have a strong focuson how to write Python
code that is freeofprogrammingmistakes.
©The Author(s) 2020
S.Linge, H.P. Langtangen, Programming forComputations -Python,
Texts in Computational Science and Engineering 15,
https://doi.org/10.1007/978-3-030-16877-3_6 131
Programming for Computations – Python
A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
- Title
- Programming for Computations – Python
- Subtitle
- A Gentle Introduction to Numerical Simulations with Python 3.6
- Volume
- Second Edition
- Authors
- Svein Linge
- Hans Petter Langtangen
- Publisher
- Springer Open
- Date
- 2020
- Language
- English
- License
- CC BY 4.0
- ISBN
- 978-3-319-32428-9
- Size
- 17.8 x 25.4 cm
- Pages
- 356
- Keywords
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Category
- Informatik