MATH40006 Practice Paper 5
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: 7435e6797e76ddc8bee35fac2443dd352e2485bd9610c8470a0a75c31caabfeaSource date: 2026-08-06
Notes — cell 1
# MATH40006 Revised Historical-Coverage Mock 5 **Time allowed:** 60 minutes **Total marks:** 50 **Questions:** 3 (20 + 20 + 10) **Role:** 2021-22 gap repair: escape-time arrays, symbolic dynamics and ordered lookup 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()
records=[('Ant','small insect'),('Bear','large mammal'),('Cat','domestic feline'),('Dog','domestic canine'),('Eel','long fish'),('Fox','wild canine'),('Goat','hoofed mammal'),('Hare','fast mammal')]
Notes — cell 3
## Question 1 (20 marks) For each complex parameter c and initial value z0, iterate z <- z**2+c. Escape occurs when abs(z)>=2. (a) Build a 220 by 220 complex grid on -1.6<=x,y<=1.6. **[3]** (b) Create an escape-time array initially -1 and use a Boolean mask to record points already escaped at time 0. **[3]** (c) Perform one iteration only on unresolved entries and record new escapes at time 1. **[3]** (d) Write `escape_time(c,z0,max_iterations)` using masks, returning `max_iterations` for unresolved points and not changing the caller's z0. **[7]** (e) Test one parameter-varying and one fixed-parameter case; display `log(times+1)` with correct origin and extent. **[4]**
Code — cell 4
# YOUR CODE HERE raise NotImplementedError()
Notes — cell 5
## Question 2 (20 marks) Let f(z)=z**2+a+i*b, with real parameters a,b. (a) Use SymPy to find the fixed points and derivative. **[2]** (b) For each fixed point form the squared derivative modulus using `re` and `im`. **[3]** (c) Lambdify the two expressions and plot their level-1 contours on an a,b grid with equal axes. **[4]** (d) Form f(f(z)), divide f(f(z))-z by f(z)-z, simplify, and solve the quotient for the genuine period-2 points. **[5]** (e) Repeat the derivative-modulus and level-1 contour calculation for the period-2 points. **[4]** (f) State what the level-1 curves represent dynamically. **[2]**
Code — cell 6
# YOUR CODE HERE raise NotImplementedError()
Notes — cell 7
## Question 3 (10 marks) A sorted list `records` of `(key,value)` pairs is supplied. (a) Write a sequential lookup returning `'failed'`. **[2]** (b) Give best- and worst-case bounds. **[1]** (c) Write a robust iterative binary lookup with the same return convention. **[4]** (d) Test a hit and two misses. **[1]** (e) Convert to a dictionary and Series, perform the hit, and time repeated successful lookups in all four structures with a restrained comment. **[2]**
Code — cell 8
# YOUR CODE HERE raise NotImplementedError()