Web-Books
im Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Seite - 105 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

Seite - 105 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Bild der Seite - 105 -

Bild der Seite - 105 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text der Seite - 105 -

4.1 PopulationGrowth 105 4.1.4 UnderstandingtheForwardEulerMethod The good thing about the ForwardEulermethod is that it gives an understanding ofwhat a differential equation is andageometrical picture ofhowto construct the solution. The first idea is thatwe have already computed the solution up to some time point tn. The second idea is thatwewant to progress the solution from tn to tnC1 asa straight line. Weknowthat the linemust go through the solutionat tn, i.e., thepoint .tn;un/. The differential equation tells us the slope of the line: u0.tn/ D f.un;tn/ D run. That is, the differential equation gives a direct formula for the furtherdirection of the solution curve. We can say that the differential equation expresses how the system(u)undergoeschangesat apoint. There is ageneral formula fora straight lineyDaxCbwith slopea thatgoes through thepoint .x0;y0/:yDa.x x0/Cy0. Using this formulaadapted to the present case, andevaluating the formulafor tnC1, results in unC1 D run.tnC1 tn/Cun DunC trun; which isnothingbut theForwardEuler formula.YouarenowencouragedtodoEx- ercise4.1 tobecomemorefamiliarwith thegeometric interpretationof theForward Eulermethod. 4.1.5 ProgrammingtheForwardEulerScheme;theGeneralCase Ourpreviousprogramwas just aflatmainprogramtailored toa specialdifferential equation.Whenprogrammingmathematics, it is alwaysgood to consider a (large) class of problemsandmakingaPython function to solveanyproblemthatfits into the class. More specifically, we will make software for the class of differential equationproblemsof the form u0.t/Df.u;t/; uDU0; t 2 Œ0;T ; for somegiven functionf , and numbersU0 andT . We also take the opportunity to illustrate what is commonly called a demo function. As the name implies, the purpose of such a function is solely to demonstrate how the functionworks (not to be confused with a test function, which does verification by use of assert). The Python function calculating the solutionmust take f ,U0, t, and T as in- put, find the correspondingNt, compute the solution, and return an array with u0;u1;:: :;uNt andanarraywith t0;t1;: : :;tNt . TheForwardEuler schemereads unC1 DunC tf.un;tn/; nD0;:: :;Nt 1: Thecorrespondingprogrammaynowtake the form(fileode_FE.py):
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python"
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
Web-Books
Bibliothek
Datenschutz
Impressum
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python