Page - 241 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Image of the Page - 241 -
Text of the Page - 241 -
8.4 Oscillating1DSystems:ASecondOrderODE 241
wechoose the bodyto beat rest, butmovedawayfromits equilibriumposition:
x(0)=X0, x′(0)=0 .
The exact solution of (8.42) with these initial conditions isx(t)=X0cosωt. This
caneasilybeverifiedbysubstituting into (8.42)andcheckingthe initial conditions.
The solution tells us that such a spring-mass system oscillates back and forth as
describedbya cosinecurve.
The differential equation (8.42)appears in numerousother contexts. A classical
example is a simple pendulumthat oscillates back and forth. Physics booksderive,
fromNewton’s second lawofmotion, that
mLθ′′+mgsinθ=0,
wherem is the mass of the body at the end of a pendulum with lengthL,g is the
acceleration of gravity, and θ is the angle the pendulum makes with the vertical.
Consideringsmall angles θ, sinθ ≈ θ, and we get (8.42)withx = θ,ω=√g/L,
x(0) = Θ, and x′(0) = 0, if Θ is the initial angle and the pendulum is at rest at
t=0.
8.4.2 NumericalSolution
We have not looked at numerical methods for handling second-order derivatives,
and such methods are an option, but we know how to solve first-order differential
equationsandevensystemsoffirst-orderequations.Witha little, yetverycommon,
trick we can rewrite (8.42) as a first-order system of two differential equations.
We introduce u = x and v = x′ = u′ as two new unknown functions. The
two corresponding equations arise from the definition v = u′ and the original
equation(8.42):
u′ =v, (8.43)
v′ =−ω2u. (8.44)
(Notice that we can use u′′ = v′ to remove the second-order derivative from
Newton’ssecond law.)
We cannowapply theForwardEulermethodto (8.43)–(8.44),exactlyaswedid
inSect. 8.3.2:
un+1 −un
Δt =vn, (8.45)
vn+1 −vn
Δt =−ω2un, (8.46)
Programming for Computations – Python
A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
- Title
- Programming for Computations – Python
- Subtitle
- A Gentle Introduction to Numerical Simulations with Python 3.6
- Volume
- Second Edition
- Authors
- Svein Linge
- Hans Petter Langtangen
- Publisher
- Springer Open
- Date
- 2020
- Language
- English
- License
- CC BY 4.0
- ISBN
- 978-3-319-32428-9
- Size
- 17.8 x 25.4 cm
- Pages
- 356
- Keywords
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Category
- Informatik