PX3143/PXT112
CARDIFF UNIVERSITY
EXAMINATION PAPER
Examination Period: Autumn
Examination Paper Number: PX3143/PXT112
Examination Paper Title: Computational Physics
Duration: 1 hour
Do not turn this page over until instructed to do so by the Senior Invigilator
Structure of Examination Paper:
There are five pages.
There are three questions in total.
There are no appendices.
The maximum mark for the examination paper is 40 (50% of the module mark)
The mark obtainable for a question or part of a question is shown in brackets alongside
the question.
Students to be provided with:
The following items of stationery are to be provided:
The following book is to be provided:
Mathematical Formulae and Physical Constants
Instructions to students:
Answer TWO questions. If additional questions are attempted be clear which should be
marked, otherwise only the first two written answers will be marked.
Calculators which have been pre-programmed and calculators with an alphabetic keyboard
are not permitted in any examination.
The use of translation dictionaries between English or Welsh and a foreign language bearing
an appropriate departmental stamp is permitted in this examination.
1
PX3143/PXT112
1. A device measuring the value of a function f(t) every 1 second produced the following
data:
t [s] -2 -1 0 1 2
f(t) -63 -4 1 0 -31
We want to utilise interpolatory integration formulas for approximating
∫ 2
−2 f(t)dt.
(a) Explain what an interpolatory integration formula is. What is the difference
between the trapezium and Simpson’s methods? Is there any problem with
interpolatory integration formulas as we increase the number of interpolation
points? (Note that data is acquired with a constant time step). 
(b) Use Simpson’s method to approximate the value of the integral considering
i. h1 = 1 s, and ii. h2 = 2 s. 
(c) We want now to utilise the results from (b) to get an even better approximation
by means of Richardson’s extrapolation. This method uses two approximations
Ih1 and Ih2 (utilising h1 and h2, respectively) to provide the exact (i.e. errorless)
value of the integral I, resulting in
I =
Ih1
(
Eh2
Eh1
)
− Ih2
Eh2
Eh1
− 1
,
where Eh1 = − 145f (4)(ξ2) and Eh2 = −1645f (4)(ξ1) are their corresponding trun-
cation errors for the values from the previous exercise (with ξ1, ξ2 ∈ [−2, 2]).
Obtain the expression for Richardson’s method assuming f (4)(ξ1) ≈ f (4)(ξ2).
Under which condition is this a valid assumption? 
(d) If the function originating the data was f(t) = −3t4+2t3+1, show that Richard-
son’s method provides an exact result, and explain why the approximations ob-
tained in (b) have errors. Does the composite Simpson’s rule provide an exact
result when h = 0.01? 
2
PX3143/PXT112
2. The electric current i(t) in a resistor-inductor (RL) series circuit satisfies the following
differential equation
U = i(t)R+ L
di(t)
dt
,
where U = 1 V, R = 1 Ω, and L = 2 H. We aim to solve the differential equation by
means of Euler’s method.
(a) Derive the general expressions for both explicit and implicit Euler’s methods
using numerical integration and considering the generic initial value problem
y′(t) = f(t, y(t)) with y(t0) = y0. Which are the advantages and disadvantages
of each of them? 
(b) Assume that we are given the solution of the differential equation at t10 = 10 s,
i(t10) = 0.9 A, and want to find the current at t8 = 8 s. Explain why, in this
case, the implicit version of Euler’s method may be more convenient. Use it to
approximate i(t8 = 8 s) considering a step size h = 1 s. 
(c) A capacitor is now included in the circuit, resulting in a resistor-inductor-
capacitor (RLC) series circuit. The electric current in this RLC circuit satisfies
the following differential equation
L
d2i(t)
dt2
+R
di(t)
dt
+
1
C
i(t) = 0,
with C = 1 F. If the electric current at the initial time t0 = 0 s satisfies
i(t0) = 0 A and i
′(t0) = 1 A/s, compute the value of the current at t2 = 2 s
using Euler’s method and a step size equal to 1 s. 
3 Turn over
PX3143/PXT112
3. We want to compute the parameter H in a two dimensional bar of size 3 × 400 as
shown in figure a (we assume all parameters are in the corresponding units). The
parameter H satisfies the equation
∂H(x, y)
∂x
+
∂2H(x, y)
∂y2
= 0,
and is subject to the boundary conditions H(0, y) = 10y, H(x, 3) = 30 + 10x, and
H(x, 0) = 10x.
(a) Discretise the partial differential equation using a centred difference scheme with
error O(h2) in each dimension, and present the corresponding stencil. What is
the order of the truncation error of the resulting methodology? 
(b) If we are interested in computing the parameter H at the very end of the bar
only, which problems do you envisage for using the centred-difference stencil? 
4
PX3143/PXT112
(c) To solve the problems from the previous point, a student proposes to use the
stencil shown in figure b. Find the numbers for each unknown in the stencil.
What is the order of the truncation error of the resulting methodology? 
(d) Using the stencil presented in Figure b, calculate the numerical solution at
points 1 and 2 in Figure a considering a step size h = 2 in the x direction, and
k = h/2 in the y direction. If you did not solve (c), consider the central element
of the stencil (that connected to the other three) equal to −4k and the other
three elements equal to 1/(h+ k). 
5X 