PHYS 481 Assignment 2: ODEs
Due: Sept 26 before class starts (15:30)
This assignment will introduce some ODE techniques. This material is discussed well in Chapters 22 and
23 of https://pythonnumericalmethods.berkeley.edu/notebooks/Index.html . Please use only numpy and
matplotlib (not scipy). Remember to write an introduction [2 pts] and conclusion [2 pts].
Question 1 [5 pts total]
a. For the equation π¦ ′′ + sin(π‘) + 1 = 0 write down the set of first-order ODEs in terms of the
state vector π = [π¦, π¦ ′ ]π (see notes, or chapter 22). This is only about 1 or 2 lines. (Don’t
overthink it!)
b. Write a general function to integrate second-order ODEs using Euler’s method. The function
should accept a function πΉ = ππ/ππ‘ (which depends on π and π‘), an interval, an initial value
vector π and a number of steps to integrate. It should return the step points π₯π and the solution
π
to the ODE π¦π at all the step points. Use it to integrate the ODE from part a on the interval [0, 2 ]
with the initial values π¦(0) = 0 and π¦ ′ (0) = 1. Compare the results using different numbers of
steps and compare to the analytic result π¦ = π1 + π2 π₯ −
π₯2
2
+ sinβ‘(π₯).
c. Repeat part b but use RK4 integration instead of Euler’s method.
d. Discuss the results.
Question 2 [5 pts total]
a. For π¦ ′′ + sin(π‘) + 1 = 0 (same ODE as in question 1) and the boundary values π¦(0) = 0 and
π
2
π
2
π¦ ( ) = 1, use a shooting method to solve the equation on the interval [0, ]. Compare to the
analytic result.
b. Repeat question a using a finite difference method with a varying number of grid points
(5,10,20,50).
c. Discuss the results.
Question 3 [5 pts]
The deflection π¦(π₯) of a 1-D beam is governed by the following ODE:
3/2
π2 π¦ 1
ππ¦ 2
2
πΈπΌ 2 = π0 (πΏπ₯ − π₯ ) [1 + ( ) ]
ππ₯
2
ππ₯
where πΈπΌ is a parameter known as the “flexural rigidity” that depends on the material and its crosssection, πΏ is the length of the beam and π0 is the load per unit length applied to the beam. If πΏ = 5 m,
πΈπΌ = 1.8 × 107 Nm2, π0 = 1.5 × 104 N/m and π¦(0) = π¦(πΏ) = 0, find the beam deflection π¦(π₯) on the
interval [0, πΏ]. [https://pythonnumericalmethods.berkeley.edu/notebooks/chapter23.06-Summary-andProblems.html question 10]