Seite - 285 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Bild der Seite - 285 -
Text der Seite - 285 -
8.6 Exercises 285
Filename:osc_FE_general.py.
Exercise8.24:SolvingaNonlinearODEwithBackward Euler
Lety bea scalar functionof time t andconsider thenonlinearODE
y′+y= ty3, t∈ (0,4), y(0)= 1
2 .
a) Assumeyouwant tosolvethisODEnumericallybytheBackwardEulermethod.
Derive the computational scheme and show that (contrary to the Forward Euler
scheme) you have to solve a nonlinear algebraic equation for each time step
whenusing this scheme.
b) Implement the scheme in a program that also solves the ODE by a Forward
Eulermethod.WithBackwardEuler,useNewton’smethodtosolvethealgebraic
equation.Asyour initial guess,youhaveonegoodalternative,whichone?
Let your program plot the two numerical solutions together with the exact
solution,which isknown(e.g., fromWolframAlpha) tobe
y(t)= √
2√
7e2t+2t+1 .
Filename:nonlinBE.py.
Exercise8.25:DiscretizeanInitial Condition
Assume that the initial condition on u′ is nonzero in the finite difference method
fromSect. 8.4.12:u′(0)=V0. Derive thespecial formulaforu1 in thiscase.
Filename:ic_with_V_0.pdf.
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0
International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing,
adaptation,distributionandreproduction inanymediumor format, as longasyougiveappropriate
credit to the original author(s) and thesource, provide a link to theCreative Commons licenceand
indicate ifchanges were made.
The images or other third party material in this chapter are included in the chapter’s Creative
Commons licence, unless indicated otherwise in a credit line to the material. If material is not
included in the chapter’s Creative Commons licence and your intended use is not permitted by
statutory regulation orexceeds thepermitted use, you willneed toobtain permission directly from
thecopyright holder.
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