Seite - 133 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Bild der Seite - 133 -
Text der Seite - 133 -
6.1 Basic IdeasofNumerical Integration 133
where
h= b−a
n . (6.4)
That is, we getn sub-intervalsof the same sizeh. Given the integrationpoints, the
original integral is re-written as a sum of integrals, each integral being computed
over the sub-interval between two consecutive integration points. The integral
in (6.2) is thusexpressedas
∫ b
a f(x)dx= ∫ x1
x0 f(x)dx+ ∫ x2
x1 f(x)dx+ . . .+ ∫ xn
xn−1 f(x)dx. (6.5)
Note thatx0 =a andxn=b.
Proceeding from (6.5), the different integration methods will differ in the way
theyapproximateeach integralon the righthand side. The fundamental idea is that
each termisan integralovera small interval [xi,xi+1], andover this small interval,
itmakessense toapproximatef byasimpleshape,sayaconstant,astraight line,or
aparabola, thatcanbeeasily integrated.Thedetailswillbecomeclear in thecoming
examples.
Computational Example To understand and compare the numerical integration
methods, it isadvantageoustouseaspecificintegralforcomputationsandgraphical
illustrations. In particular, we want to use an integral that we can calculate
by hand such that the accuracy of the approximation methods can easily be
assessed.
Ourspecific integral is takenfrombasicphysics.Assumethatyouspeedupyour
car from rest, on a straight road, and wonder how far you go in T seconds. The
displacement is given by the integral ∫T
0 v(t)dt, where v(t) is the velocity as a
functionof time.A rapidly increasingvelocity functionmightbe
v(t)=3t2et3 . (6.6)
Thedistance traveled in1s is then
∫ 1
0 v(t)dt, (6.7)
which is the integralweaim tocomputebynumericalmethods.
By hand,weget
∫ 1
0 3t2et 3 dt= [
et 3 ]1
0 ≈1.718, (6.8)
which is roundedto 3decimals forconvenience.
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