Semester 2 Assessment, 2020
School of Mathematics and Statistics
MAST30028 Numerical Methods & Scientific Computing This exam consists of 8 pages (including this page)
Authorised materials:
• The subject website hosted on the Learning Management System (LMS). • Any part of the provided software system MATLAB.
• Blank A4 paper.
Instructions to Students
• It is not an open book exam. You can only access specified authorized materials and should not access the internet for any other materials.
• This is a strict time limit exam. You have 30min reading time, 3hrs to finish, and 30mins to submit your work via LMS. The submitting page will close automatically after 240mins.
• Write your answers and put your numerical results into a document (e.g. Microsoft Word) file on computer. Start each question on a new page. Write the question number. For some questions, you can write on a piece of paper.
• Scan any writing response on paper into a single PDF file using a proper scanning app such as Camscanner, Scannable or OfficeLens. Do not just take photos with your phone camera as this produces large files that you may not be able to upload. Scan from directly above to avoid any excessive keystone effect. Check that all pages are clearly readable and cropped to the A4 borders of the original page. Poorly scanned submissions may be impossible to mark.
• Upload the document file(s) (including your numerical results, comments, and other writ- ings) and the zip file (including all m-files) via the Canvas Assignments menu.
• You should attempt all questions.
• Full reasoning must be shown and penalties may be imposed for poorly presented, unclear,
untidy and badly worded solutions.
• There are 7 questions with marks as shown. The total number of marks available is 80.
Supplied by download for enrolled students only—©c University of Melbourne 2020
Student Number
MAST30028 Semester 2, 2020
Question 1 (6 marks) Solve the initial value problem
y′ = −36[y − cos(t)] − sin(t)
over the interval [0, 1], with y(0) = 1, using Euler’s method, with h = 0.1,0.01,0.001. Using plots of the solutions in each case as evidence, explain which solutions are correct and the reason why in terms of concepts covered in this subject.
You may use any code used in the Labs.
Page 2 of 8 pages
MAST30028 Semester 2, 2020 Question 2 (9 marks) Consider the following procedure for determining the limit lim (eh − 1)/h
on a computer. Let
dn =fl!e2−n −1″ 2−n
h→0
for n = 0, 1, 2, . . . and accept as the machine limit the first value satisfying dn = dn−1.
(a) Write a MATLAB function examQ2.m implementing the procedure. Your MATLAB
function should return dn and n.
(b) In double precision floating-point arithmetic, with rounding by chopping, for what value
of n will the correct limit be reached, assuming no underflow (of 2−n) occurs? (Hint: use
eh = 1 + h + 1 h2 + · · · ) 2
(c) Compare the theoretic result n in (b) with the experiment made in (a).
Page 3 of 8 pages
MAST30028 Semester 2, 2020 Question 3 (9 marks) Explain the output of the following MATLAB code:
(a) n = 60;
A = toeplitz([1, -ones(1,n-1)], [1, zeros(1,n-1)]); A(:, n) = 1; x = rand(n,1); b = A*x;
x1 = A\b;
norm(x-x1)/norm(x)/norm(A)
(b) n = 60;
A = rand(n);
x = rand(n,1); b = A*x;
x1 = A\b;
norm(x-x1)/norm(x)/norm(A)
(c) n = 10;
A = hilb(n);
x = rand(n,1); b = A*x;
x1 = A\b;
norm(x-x1)/norm(x)/norm(A)
Page 4 of 8 pages
ing whether or not there is a match.
MAST30028 Semester 2, 2020
P3
P2
Write a program to estimate the probability that three random points on the ed of a square form an obtuse triangle (see the figure). Hint: Use the Law of Cosin
Question 4 (12 marks) Let p be the probability that three random points on the edges of the u2nit squa2re form2an obtuse triangle (see the figure).
cosθ=(b +c −a)/2bc.
c
a
b
P1 (a) Write a MATLAB function with calling sequence
A histogram is a graphical device for displaying frequencies by means of rect function [p, stderror] = approxProb(Nreps)
gles whose heights are proportional to frequencies. For example, in throwing t
to estimate the probability p. Your MATLAB function should return your estimate of
dice 3600 times, the resulting sums 2, 3, . . . , 12 should occur with frequencies cl
p and the standard error fo the estimator, given the number of repetitions as an input
to those shown in the histogram below. By means of a Monte Carlo simulati
argument.
obtain a histogram for the frequency of digits 0, 1, . . . , 9 that appear in 1000 rand (b) Run the simulation 10 times and print the probability p with 4 decimal places for Nreps =
numbers.
100 and N reps = 10, 000, respectively. Describe what do you observed.
(c) Determine by simulation the number of repetitions for the standard error to be less than
1 × 10−3, i.e. the estimate for p should have 2 decimal place accuracy. 600
(d) Estimate the number of repetitions you would need for 3 decimal place accuracy. Explain your answer.
500
400
300
200
100
2 3 4 5 6 7 8 9 10 11 12
Outcome
Consider a circular city of diameter 20 kilometers (see the following figure). Radiati from the center are 36 straight roads, spaced 10◦ apart in angle. There are also 20 circu roads spaced 1 kilometer apart. What is the average distance, measured along the roa between road intersection points in the city?
Page 5 of 8 pages
(r, )
g e
a w
o o o
n l
d
Frequency
MAST30028 Semester 2, 2020 Question 5 (12 marks) A bacterial population P grows according to the geometric progression
Pk = rPk−1
where r is the growth rate. The following population counts (in billions) are observed
(a) Perform a nonlinear least-square fit of the growth function to these data to estimate the initial population P0 and the growth rate r. You are supposed to use lsqcurvefit with Levenberg-Marquardt algorithm and pick initial guesses P0 = 1 and r = 2.
(b) By transform the data to new variables in which the model appears linearly in the pa- rameters. Now fit the transformed data to a line by constructing a suitable linear system and using \. Report the corresponding parameters P0 and r.
(c) By plotting the data and both fits in (a) and (b) on the same plot, decide which method gives the best fit for this data.
k
1
2
3
4
5
6
7
8
Pk
.19
.36
.69
1.3
2.5
4.7
8.5
14
Page 6 of 8 pages
MAST30028 Semester 2, 2020 Question 6 (15 marks) One variant of Newton’s method for solving the equation f(x) = 0 uses
the formula
in which g(x) = f(x+f(x))−f(x).
xn+1 = xn − f(xn) g(xn)
f (x)
(a) Using Taylor series, show that the iteration xn+1 = xn − f (xn ) relates to Newton’s iteration
g(xn)
(b) Modify Newton.m to produce a function ModifiedNewton.m that implements this method.
(c) Write a driver function to call ModifiedNewton.m. Compare the performance of Newton’s method with that of ModifiedNetwon.m on the equation
exp(−x2) − x = 0
with x0 = 1 and a relative tolerance (only) of 10−12. Suitable plots may be useful. Based on your results, describe the behavior of the modified Newton’s method compared to Newton’s method.
(d) Describe what advantage does the modified Newton’s method have.
(e) Establish the convergence rate for the modified Newton’s method for the simple root case.
You may use any code used in the Labs.
if f(x) is small.
Page 7 of 8 pages
MAST30028 Semester 2, 2020
Question 7 (17 marks) The following equation models a combustion process: y′ =y2(1−y)
where y(0) = δ, a parameter, and we want the solution over the interval [0, 2δ−1].
Write a function M-file examQ7.m with no output arguments and input argument delta
function examQ7(delta)
as a driver to do the following:
• Solve this equation using a call to the Matlab build-in solver ode113. Use the command options = odeset(Stats,on) to produce measures of the work taken by the computa- tion. Use tic and toc to measure the computation time taken.
• Plot the solution and show a plot that illustrates the stepsize variation during the com- putation.
• Repeat the solution but with no output argument (so it plots as it goes) to see what’s going on.
• Repeat the above but using the solver ode15s.
Now run your driver for δ = 10−1, 10−2, 10−3, 10−4. Using the output of your computation as
evidence, describe
(a) how does the nature of the equation change as t passes δ−1?
(b) how does the nature of the equation change as δ changes?
(c) one method produces output such as (FOR EXAMPLE)
13 LU decompositions
64 solutions of linear systems
and the other doesn’t; why?
(d) which method would you recommend for this problem, and why?
Reminder: You may use any code used in the Labs. You may answer in a document (e.g. Microsoft Word). Include any relevant output and plots in the document as evidence to support your answers. Then convert the document into pdf.
End of Exam—Total Available Marks = 80
Page 8 of 8 pages