Web-Books
in the Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Page - 65 -
  • User
  • Version
    • full version
    • text only version
  • Language
    • Deutsch - German
    • English

Page - 65 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Image of the Page - 65 -

Image of the Page - 65 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text of the Page - 65 -

3.3 TheCompositeMidpointMethod 65 Thepresent integralproblemsresult inshortcode. Inmorechallengingengineer- ingproblems the codequicklygrows tohundredsand thousandsof lines. Without abstractions in termsofgeneral algorithms ingeneral reusable functions, the com- plexityof theprogramgrowsso fast that itwill beextremelydifficult tomakesure that theprogramworksproperly. Another advantage of packagingmathematical algorithms in functions is that a functioncanbe reusedbyanyone to solve aproblemby just calling the function with a proper set of arguments. Understanding the function’s inner details is not necessary to compute a new integral. Similarly, youcanfind libraries of functions on the Internet and use these functions to solve your problems without specific knowledgeofeverymathematicaldetail in the functions. This desirable feature has its downside, of course: the user of a functionmay misuse it, and the functionmaycontainprogrammingerrorsand lead towrongan- swers. Testing theoutputofdownloadedfunctions is thereforeextremely important before relyingon the results. 3.3 TheCompositeMidpointMethod The idea Rather thanapproximating theareaundera curveby trapezoids,wecan use plain rectangles (Fig. 3.3). Itmay sound less accurate to use horizontal lines andnotskewlinesfollowingthefunctiontobeintegrated,butanintegrationmethod basedonrectangles (themidpointmethod) is in fact slightlymoreaccurate than the onebasedon trapezoids! Fig.3.3 Computing approximately the integral of a function as the sumof the areas of the rect- angles
back to the  book Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python
Title
Programming for Computations – Python
Subtitle
A Gentle Introduction to Numerical Simulations with Python
Authors
Svein Linge
Hans Petter Langtangen
Publisher
Springer Open
Date
2016
Language
English
License
CC BY-NC 4.0
ISBN
978-3-319-32428-9
Size
17.8 x 25.4 cm
Pages
248
Keywords
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Category
Informatik
Web-Books
Library
Privacy
Imprint
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python