MATH40006 Practice Paper 1
English review edition prepared on 4 October 2026 from a preserved source copy. It is a later presentation, not the historical study interface. Source checks and difficulty judgements describe the original material author's own process; they do not indicate Imperial College London endorsement.
Source SHA-256: 8119bf853c4311bb221d17e4a87ca44e4a44674310a563715bc205ccb2eef136Source date: 2026-08-06
Notes — cell 1
# MATH40006 Revised Historical-Coverage Mock 1 **Time allowed:** 60 minutes **Total marks:** 50 **Questions:** 3 (20 + 20 + 10) **Role:** 2025-26 regular-assessment structure reinforcement (the only deliberately close paper) Answer all questions in this Jupyter notebook. Show testing code and outputs. Unless the question explicitly requests an in-place operation, functions should return a value without changing their inputs.
Code — cell 2
import numpy as np import sympy as sp import matplotlib.pyplot as plt import pandas as pd from time import perf_counter from copy import copy import pickle import ast import math sp.init_printing()
Notes — cell 3
## Question 1 (20 marks) Let `v(x,y) = x**2/2 + sin(y)` on `-2 <= x <= 2` and `-pi <= y <= pi`. (a) Define one-dimensional NumPy arrays `x_values1` and `y_values1` containing 121 equally spaced points on the stated intervals. **[2]** (b) Use `meshgrid` to define the corresponding 121 by 121 arrays `x1` and `y1`. **[2]** (c) Display `v(x1,y1)` with `imshow`, using correct `origin` and `extent`. **[3]** (d) Draw a contour plot of the same scalar field. **[2]** (e) Construct 21-point coordinate arrays and corresponding meshgrid arrays `x2,y2`. **[3]** (f) Since `v_x=x` and `v_y=cos(y)`, draw the field `(v_y,-v_x)` with `quiver` on the coarse grid. **[3]** (g) Superimpose blue vectors on red contours. **[2]** (h) Draw the surface `z=v(x,y)` with `plot_wireframe`. **[3]**
Code — cell 4
# YOUR CODE HERE raise NotImplementedError()
Notes — cell 5
## Question 2 (20 marks) This question revisits the Pritchard sieve using `n=47` and asks you to reconstruct the algorithm rather than merely copy a finished function. (a) Experiment with `np.tile([True,False,True],4)` and `np.flatnonzero([0,5,0,2])`. State what each function returns or does. **[2]** (b) Set `n=47`, `sieving_array=np.array([True])`, `discards` to a Boolean array of length `n+2` containing `False`, and `l,p=1,2`. **[3]** (c) Execute one complete Pritchard update: mark `p`; extend the periodic Boolean array if required; remove the current prime and its later multiples; locate the next prime candidate with `flatnonzero`. Print the resulting `l` and `p`. **[5]** (d) Write `pritchard_sieve(n)` implementing the complete loop with stopping condition `min(p**2,l+1)>n`. Return all primes from 2 to `n` inclusive. **[7]** (e) Test `n=1,2,3,47` and one five-digit input; verify that every returned value is prime and that 1 is absent. **[3]**
Code — cell 6
# YOUR CODE HERE raise NotImplementedError()
Notes — cell 7
## Question 3 (10 marks) For two NumPy vectors `[a,b]` and `[c,d]`, their mediant vector is `[a+c,b+d]`. (a) Write `neighbor_mediants(lis)` for each adjacent pair. **[2]** (b) Write `interleave(left,middle)` so that a list and its between-item values alternate, and use it to define `refine(lis)`. **[2]** (c) Starting from `[array([0,1]),array([1,1]),array([1,0])]`, apply `refine` `n` times and return the odd-indexed entries as SymPy `Rational`s in `sb_generation(n)`. **[4]** (d) Test generations 0 and 3. **[2]**
Code — cell 8
# YOUR CODE HERE raise NotImplementedError()