Seite - 91 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Bild der Seite - 91 -
Text der Seite - 91 -
3.8 Exercises 91
The integrandxx doesnothaveananti-derivative that canbeexpressed in termsof
standard functions (visit http://wolframalpha.comand typeintegral(x**x,x) to
convince yourself that our claim is right. Note thatWolframalpha does give you
an answer, but that answer is an approximation, it is not exact. This is because
Wolframalpha toousesnumericalmethods to arriveat the answer, just asyouwill
in this exercise). Therefore, we are forced to compute the integral by numerical
methods.Computea result that is right to fourdigits.
Hint Use ideas fromExercise3.9.
Filename:integrate_x2x.py.
Exercise3.11: Integrateproductsof sine functions
In this exerciseweshall integrate
Ij;k D Z
sin.jx/sin.kx/dx;
wherej andk are integers.
a) Plot sin.x/sin.2x/ and sin.2x/sin.3x/ forx 2 ; in separate plots. Ex-
plainwhyyouexpect R sinxsin2xdxD0and R sin2xsin3xdxD0.
b) Use the trapezoidal rule tocomputeIj;k forj D1;:: :;10andkD1;:: :;10.
Filename:products_sines.py.
Exercise3.12:Revisitfitof sines toa function
This is acontinuationofExercise2.18. The task is toapproximateagivenfunction
f.t/on Œ ; byasumofsines,
SN.t/D NX
nD1 bnsin.nt/: (3.27)
We are now interested in computing the unknowncoefficients bn such thatSN.t/
is in some sense the best approximation tof.t/. One commonway of doing this
is to first set up a general expression for the approximation error, measured by
“summingup” thesquareddeviationofSN fromf :
E D Z
.SN.t/ f.t//2dt :
We may view E as a function of b1;:: :;bN. Minimizing E with respect to
b1;:: :;bN willgiveusabestapproximation, in thesense thatweadjustb1;:: :;bN
such thatSN deviatesas little aspossible fromf .
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