Web-Books
im Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Seite - 158 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

Seite - 158 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Bild der Seite - 158 -

Bild der Seite - 158 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Text der Seite - 158 -

158 6 ComputingIntegralsandTestingCode howcanwe approximate this integralbynumericalmethods? Derivation via One-Dimensional Integrals Since we know how to deal with integrals in one variable, a fruitful approach is to view the double integral as two integrals,each inonevariable,whichcanbeapproximatednumericallybyprevious one-dimensionalformulas.To thisend,we introduceahelpfunctiong(x)andwrite ∫ b a ∫ d c f(x,y)dydx= ∫ b a g(x)dx, g(x)= ∫ d c f(x,y)dy. Eachof the integrals ∫ b a g(x)dx, g(x)= ∫ d c f(x,y)dy can be discretized by any numerical integration rule for an integral in one variable. Let us use the midpoint method (6.20) and start with g(x) = ∫d c f(x,y)dy. We introduceny intervals on [c,d]with lengthhy. The midpoint rule for this integral thenbecomes g(x)= ∫ d c f(x,y)dy≈hy ny−1∑ j=0 f(x,yj), yj = c+ 1 2 hy+jhy . The expression looks somewhat different from (6.20), but that is because of the notation:sinceweintegrate in theydirectionandwillhavetoworkwithbothx and y ascoordinates,wemustuseny forn,hy forh, and thecounter i ismorenaturally called j when integrating iny. Integrals in thex direction will usehx andnx forh andn, and i ascounter. The double integral is ∫b a g(x)dx, which can be approximated by the midpoint method: ∫ b a g(x)dx≈hx nx−1∑ i=0 g(xi), xi =a+ 1 2 hx+ ihx . Putting the formulas together, we arrive at the composite midpoint method for a double integral: ∫ b a ∫ d c f(x,y)dydx≈hx nx−1∑ i=0 hy ny−1∑ j=0 f(xi,yj) =hxhy nx−1∑ i=0 ny−1∑ j=0 f(a+ hx 2 + ihx,c+ hy 2 +jhy). (6.29)
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition"
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
Web-Books
Bibliothek
Datenschutz
Impressum
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python