Seite - 161 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Bild der Seite - 161 -
Text der Seite - 161 -
6.7 DoubleandTriple Integrals 161
LetTest FunctionsSpeakUp?
Ifwecall theabovetest_midpoint_doublefunctionandnothinghappens,
our implementations are correct. However, it is somewhat annoying to have
a function that is completely silent when it works—arewe sure all thingsare
properlycomputed?Duringdevelopment it is thereforehighly recommended
to insert a print command such that we can monitor the calculations and be
convinced that the test function does what we want. Since a test function
should not have any print command, we simply comment it out as we have
done in the function listedabove.
The trapezoidal method can be used as alternative for the midpoint method.
The derivationof a formula for the double integral and the implementations follow
exactly the same ideas as we explained with the midpoint method, but there are
more terms towrite in the formulas.Exercise6.13asksyou to carryout the details.
That exercise is a very good test on your understanding of the mathematical and
programmingideas in thepresent section.
6.7.2 TheMidpointRuleforaTripleIntegral
Theory Once a method that works for a one-dimensional problem is generalized
to two dimensions, it is usually quite straightforward to extend the method to three
dimensions.Thiswillnowbedemonstratedfor integrals.Wehavethe triple integral
∫ b
a ∫ d
c ∫ f
e g(x,y,z)dzdydx
andwant toapproximatethe integralbyamidpointrule.Followingthe ideas for the
double integral,we split this integral intoone-dimensional integrals:
p(x,y)= ∫ f
e g(x,y,z)dz
q(x)= ∫ d
c p(x,y)dy
∫ b
a ∫ d
c ∫ f
e g(x,y,z)dzdydx= ∫ b
a q(x)dx
Programming for Computations – Python
A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
- Titel
- Programming for Computations – Python
- Untertitel
- A Gentle Introduction to Numerical Simulations with Python 3.6
- Band
- Second Edition
- Autoren
- Svein Linge
- Hans Petter Langtangen
- Verlag
- Springer Open
- Datum
- 2020
- Sprache
- englisch
- Lizenz
- CC BY 4.0
- ISBN
- 978-3-319-32428-9
- Abmessungen
- 17.8 x 25.4 cm
- Seiten
- 356
- Schlagwörter
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Kategorie
- Informatik