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

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

Image of the Page - 56 -

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

Text of the Page - 56 -

56 3 Computing Integrals Themajor problemwith this procedure is thatwe need to find the anti-derivative F.x/ corresponding to agivenf.x/. For some relatively simple integrandsf.x/, findingF.x/ is a doable task, but it can very quickly become challenging, even impossible! Themethod (3.1) provides an exact or analytical value of the integral. If we relax the requirementof the integralbeingexact, and instead look forapproximate values,producedbynumericalmethods, integrationbecomesaverystraightforward task foranygivenf.x/ (!). Thedownsideof anumericalmethod is that it canonlyfindanapproximatean- swer. Leavingtheexactfor theapproximateisamentalbarrier in thebeginning,but remember thatmost real applications of integrationwill involve anf.x/ function that contains physical parameters, which aremeasuredwith some error. That is, f.x/ is veryseldomexact, and then it doesnotmakesense tocompute the integral witha smaller error than theonealreadypresent inf.x/. Another advantageofnumericalmethods is thatwecan easily integrate a func- tion f.x/ that is only known as samples, i.e., discrete values at some x points, andnot as a continuous functionofx expressed througha formula. This is highly relevantwhenf ismeasured inaphysicalexperiment. 3.1 BasicIdeasofNumerical Integration Weconsider the integral bZ a f.x/dx: (3.2) Most numericalmethods for computing this integral split up the original integral into a sum of several integrals, each covering a smaller part of the original inte- gration interval Ε’a;b . This re-writing of the integral is based on a selection of integration points xi, i D 0;1;:: :;n that are distributed on the interval Ε’a;b . Integrationpointsmay,ormaynot,beevenlydistributed.Anevendistributionsim- plifiesexpressionsandisoftensufficient, sowewillmostlyrestrictourselves tothat choice. The integrationpoints are thencomputedas xi DaC ih; i D0;1;:: :;n; (3.3) where hD b a n : (3.4) Given the integration points, the original integral is re-written as a sum of inte- grals, each integral beingcomputedover the sub-intervalbetween twoconsecutive integrationpoints. The integral in (3.2) is thusexpressedas bZ a f.x/dxD x1Z x0 f.x/dxC x2Z x1 f.x/dxC : : :C xnZ xn 1 f.x/dx: (3.5) Note thatx0 Da andxn Db.
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