Beruflich Dokumente
Kultur Dokumente
This assessment is marked out of 45 and comprises 40% of the final course mark.
Academic misconduct
The assessment is primarily summative in nature. You are expected to be aware of and abide by University policies on academic
misconduct.
If you use any resources (e.g. textbooks or websites) then include appropriate references in your solutions. Course materials do not
need to be referenced.
Markdown
In workshops you have edited Jupyter Notebook "code" cells. Cells can also contain formatted text in "markdown" cells. Some
questions ask for further discussion and explanation, which should be provided in appropriate markdown cells. You may wish to use
formatting features of markdown cells, although this is optional.
You can edit markdown cells (e.g the cell initially containing "Discussion for question 1.1" in question 1) by double clicking on them,
and render the markdown by selecting the cell and pressing Shift+Return.
Code commentary
Your code should be extensively commented, with the functionality of each line of code explained with a comment. This is to test your
understanding of the code you have written. Up to half of the marks associated with the coding part of a question may be deducted
for a missing, incomplete, or inaccurate code commentary.
In [ ]:
def is_prime(n):
"""
Return whether an input positive integer is prime.
"""
if n == 1: # If n is 1 ...
return False # ... then n is not prime
Rerun your code cells after editing your code, to make sure that the output is updated.
On lab computers make sure you save edited notebook files in an appropriate location, as otherwise they may be lost when you
logout.
2
Consider a triangle in R whose vertices have coordinates
( ) ( ) ( )( ) (
x0, y0 = (1, 1), x1, y1 = 2 + 1ε, 2 + 1ε , x2, y2 = 2 − 2ε1 + ε, 2 + 2ε1 + ε , )
where ε is some positive real value.
The area of a triangle can be computed using Heron's formula (see section 1 of W. Kahan, referenced above)
A = √s(s − a)(s − b)(s − c) ,
where s = (a + b + c)/2, and a, b, and c are the lengths of the three sides of the triangle.
1.1 Compute the area of the above triangle using Heron's formula and floating point arithmetic, for different values of ε. Investigate
and discuss what happens for small values of ε. Investigate other ways of computing the area of the triangle.
Summarise and explain your results in a discussion of no more than 350 words.
Your code should be well laid out and easy to understand. You should make appropriate use of output and plots.
[10 marks]
In [ ]:
# Code for question 1.1
2.1 The degree p Chebyshev points are the roots of the degree p Chebyshev polynomial. Write a function which accepts a positive
integer p, defining the Chebyshev polynomial degree, and returns the degree p Chebyshev points, as a NumPy vector. You may wish
to make use of functionality provided by the following NumPy module
NumPy: numpy.polynomials.chebyshev
[2 marks]
{
Hint: For p = 3 the Chebyshev points are − √3/2, 0, √3/2 . }
2.2 Find the quadrature weights wi (for i ∈ {1, …, p}) associated with interpolatory quadrature rules whose quadrature points xi are
the associated degree p Chebyshev points, for different values of p.
and compare the result against the exact value, obtained using SymPy.
[7 marks]
2.3 Investigate the accuracy of the quadrature rules obtained for different values of p.
Summarise and explain your results in a discussion of no more than 250 words.
[7 marks]
Your code should be well laid out and easy to understand. You should make appropriate use of displayed output and plots.
Your code should be well laid out and easy to understand. You should make appropriate use of displayed output and plots.
In [ ]:
# Code for questions 2.1--2.3
3.1 Plot this function on the intervals x ∈ [−0.5, 1.5] and x ∈ [−0.5, 5]. Use the SciPy optimize.fsolve function to find values for
the roots of F(x) in the interval x ∈ [−0.5, 5].
Your code should be well laid out and easy to understand. Your plots should be appropriately formatted. You should make
appropriate use of displayed output.
[4 marks]
In [ ]:
# Code for question 3.1
3.2 Use Newton's method, and two other root finding methods, to seek the roots of F(x) in the interval x ∈ [−0.5, 5], identified in
question 3.1.
Investigate the convergence properties of Newton's method for this problem, for each of the roots, and compare this against the
convergence properties of the other methods.
Summarise and explain your results in a discussion of no more than 500 words.
Your code should be well laid out and easy to understand. You should make appropriate use of displayed output and plots.
[15 marks]
In [1]:
# Code for question 3.2