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

Seite - 78 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Bild der Seite - 78 -

Bild der Seite - 78 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text der Seite - 78 -

78 3 Computing Integrals In [6]: %timeit midpoint_vec(v, 0, 1, 1000000) 1 loops, best of 3: 379 ms per loop In [7]: %timeit midpoint(v, 0, 1, 1000000) 1 loops, best of 3: 8.17 s per loop In [8]: 8.17/(379*0.001) # efficiency factor Out[8]: 21.556728232189972 Wesee that the vectorized version is about 20 times faster: 379ms versus 8.17s. Theresults for the trapezoidalmethodareverysimilar, and thefactorofabout20 is independentof thenumberof intervals. 3.7 DoubleandTripleIntegrals 3.7.1 TheMidpointRuleforaDoubleIntegral Givenadouble integralovera rectangulardomain Œa;b Œc;d , bZ a dZ c f.x;y/dydx; howcanweapproximate this integralbynumericalmethods? Derivation via one-dimensional integrals Sincewe know how to deal with in- tegrals in one variable, a fruitful approach is to view the double integral as two integrals, eachinonevariable,whichcanbeapproximatednumericallybyprevious one-dimensionalformulas. Tothisend,weintroduceahelpfunctiong.x/andwrite bZ a dZ c f.x;y/dydx D bZ a g.x/dx; g.x/D dZ c f.x;y/dy : Eachof the integrals bZ a g.x/dx; g.x/D dZ c f.x;y/dy canbediscretizedbyanynumerical integration rule foran integral inonevariable. Let us use themidpointmethod (3.21) and start withg.x/ D Rd c f.x;y/dy. We introduceny intervals on Œc;d with lengthhy. Themidpoint rule for this integral thenbecomes g.x/D dZ c f.x;y/dy hy ny 1X jD0 f.x;yj/; yj D cC 1 2 hy Cjhy :
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python
Titel
Programming for Computations – Python
Untertitel
A Gentle Introduction to Numerical Simulations with Python
Autoren
Svein Linge
Hans Petter Langtangen
Verlag
Springer Open
Datum
2016
Sprache
englisch
Lizenz
CC BY-NC 4.0
ISBN
978-3-319-32428-9
Abmessungen
17.8 x 25.4 cm
Seiten
248
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