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

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

Image of the Page - 57 -

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

Text of the Page - 57 -

3.2 TheCompositeTrapezoidalRule 57 Proceeding from (3.5), the different integrationmethodswill differ in theway theyapproximateeach integralon the righthandside. The fundamental idea is that each termisan integraloverasmall interval Ε’xi;xiC1 , andover this small interval, itmakes sense to approximatef bya simple shape, say a constant, a straight line, oraparabola,whichwecaneasily integratebyhand.Thedetailswill becomeclear in thecomingexamples. Computational example To understand and compare the numerical integration methods, it isadvantageoustouseaspecificintegralforcomputationsandgraphical illustrations. Inparticular,wewant tousean integral thatwecancalculatebyhand such that the accuracy of the approximationmethods can easily be assessed. Our specific integral is taken frombasic physics. Assume that you speed up your car from rest andwonder how far you go inT seconds. The distance is given by the integral RT 0 v.t/dt, where v.t/ is the velocity as a function of time. A rapidly increasingvelocity functionmightbe v.t/D3t2et3 : (3.6) Thedistanceafteronesecond is 1Z 0 v.t/dt; (3.7) which is the integral we aim to compute by numericalmethods. Fortunately, the chosen expression of the velocity has a form that makes it easy to calculate the anti-derivativeas V.t/D et3 1: (3.8) Wecan therefore compute the exact valueof the integral asV.1/ V.0/ 1:718 (rounded to3decimals forconvenience). 3.2 TheCompositeTrapezoidalRule The integral Rb a f.x/dxmaybe interpreted as the areabetween thex axis and the graph y D f.x/ of the integrand. Figure 3.1 illustrates this area for the choice (3.7). Computing the integral R1 0 f.t/dt amounts to computing the area of the hatched region. If we replace the true graph in Fig. 3.1 by a set of straight line segments, we mayview thearea rather as composedof trapezoids, the areasofwhichareeasy to compute. This is illustrated inFig. 3.2,where4 straight line segments give rise to 4 trapezoids, covering the time intervals Ε’0;0:2/, Ε’0:2;0:6/, Ε’0:6;0:8/and Ε’0:8;1:0 . Note thatwehave taken theopportunityhere todemonstrate thecomputationswith time intervals thatdiffer in size.
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