Question 1:
Finite differences for ODES:
Consider the following ordinary differential equation (which is a type of Euler's equation):
x2y'' + 2xy' -6y = 4x
Consider several accompanying conditions:
IV P1 : y(1) = 0, y'(1) = 3
IV P2 : y(1) = 6, y'(1) = 3
BVP : y'(1) = 3, y(2) = 5
For the following parts use a step size h ≤ 0.5. If you are doing it by hand, it is recommended you use the largest permissible size (h = 0.5) in all calculations below.
1. Convert the differential equation into a finite difference equation. Hints: Ignore the conditions for the moment. You can use forward, backwards or centred differences for the derivative and double derivative. Several choices will work, but it is advisable to make your selections in order to minimise truncation errors.
2. Use the finite difference equation from part1 to calculate numerically for IV P1, y(2). Hint: you will need to convert the derivative condition into a finite difference equation. As before, minimise the truncation error for your choice of differences.
3. Use the finite difference equation from part1 to calculate numerically for IV P 2, y(2).
4.Use parts2 and 3 to estimate for BV P y(1).
5. Solve the differential equation for all three conditions analytically to check the accuracy of your numerical answers. Hint: apply the transformation t = ln(x) to convert to a 2nd order linear differential equation with constant coefficients.
6. Is the method used here based on finite differences more or less accurate than using the Euler method? Compare them with equal step size. Try to answer using theory (and then check using a program if you wish).
Notes: This question can be done manually by using h = 0.5. This will provide practice for the exam. For this assignment this is satisfactory (even if highly inaccurate!). However if you want reasonable accuracy, you should decrease h and use a computer program. Most marks are nevertheless awarded for the methods (eg deriving the difference equations) rather than numbers or computer programs.
Question 2:
Fourier series:
1. Find the Fourier series (by using integrals) for the half-wave rectified sine function:
f(x) = 0 -1 < x< 0
sin (Πx) 0 < x < 1
where f (x) has period 2. (This needs to be attempted by hand, but you can use Maple to check your answer.)
2. Generate graphical output for the series obtained in the previous part with 2 nonzero cosine terms for -2 ≤ x ≤ 2.
3. Generate graphical output for the series obtained in the previous part with 10 nonzero cosine terms for -2 ≤ x ≤ 2.
4. Generate graphical output for the series obtained in the previous part with 2 nonzero cosine terms and sigma-approximation for -2 ≤ x ≤ 2.
5. Generate graphical output for the series obtained in the previous part with 10 nonzero cosine terms and sigma-approximation for -2 ≤ x ≤ 2.
6. Comment on the effect that sigma-approximation has on the convergence of these (truncated) series.
Question 3:
Diffusion-advection equation:
A commonly used partial differential equation when modelling fluids is the diffusion-advection equation (also called the convection-diffusion equation). It is a combination of the heat equation (section 5.2) and advection equation (example 6.7) but we will consider it in its own right here.
Consider a river where the flow is a constant u = 0.5ms-1. At one point on the river a hydrologist is going to continually add a fixed concentration of C0 = 0.1kgm-3 of dye. The dye will flow with the water but will also diffuse according to a diffusion coefficient of D = 0.1m2s-1. Let C(x, t) be the concentration x metres downstream from the release point and t seconds from starting the release.
Furthermore at t = 0 the hydrologist has spread some more dye for the first 7.5m.
A simple model for this situation is given by the diffusion-advection equation:
∂C/∂t + ∂C/∂x = D∂2C/∂x2
We have initial time and spatial conditions (respectively) of:
C(x, 0) = f (x) = C0 (1 - x/7.5) 0 ≤ x ≤ 7.5
0 x > 7.5
C(0, t) = g(t) = C0
In this question we will develop a numerical method to solve this PDE.
1. Classify the diffusion-advection equation as hyperbolic/parabolic/elliptic/mixed.
2. Construct a finite difference equation for the diffusion-advection equation.
Some tips: one boundary is the initial time. Therefore we want to work forward in time. This should suggest what type of difference to use for the time derivative. Due to the double derivative of C being present, you will naturally have to sample values for (at least) 3 different C values. This means it does not matter so much which type of difference you use for the (single) C derivative. It is best to choose the lowest truncation error where possible.
Let xi = ih, tj = jk and Ci,j = C(xi, tj ) where h and k are step sizes. Use h = 3 and k = 5. The finite difference equation will probably be Ci,j+1 = ....
3. Use your finite difference equation to predict the value at x = 3m and t = 10s.
Note: You may use a computer program to help you here with these calculations. You can alternatively do them by hand instead.
4. How many iterations are required to evaluate the concentration at x = nh and t = mk?
(That is, how many times must you use the finite difference equation?)