{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# MA934 - Week 6 (unassessed!) Problem Sheet\n", "\n", "The problems below give you a chance to practice some of the concepts we learned about in week 1 and also provide a chance to hand in work that would receive feedback ahead of any assessed submission. This is an opportunity to double-check both if mathematical concepts are covered sufficiently thoroughly and whether implementation elements (commenting, plot creation) are likely to result in full marks.\n", "\n", "\n", "## Task 1 [10 marks]\n", "\n", "Create a notebook and implement code that reads in parameters $\\alpha$ and $n$ and produces a log plot of some samples of the function $$f(x) = x^\\alpha \\, \\log(x)$$\n", "at values of $x$ that increase in powers of 2 from 1 to $2^n$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task 2 [40 marks]\n", "\n", "Following a similar structure (including a function - or more!) to the Notebook presented in class for matrix-matrix multiplication, add to the respective code such that it can also:\n", " * execute the Strassen multiplication algorithm\n", " * plot the runtime on the same figure as the standard matrix-matrix multiplication results and compare the two\n", " \n", "Note: you may benefit from reducing the size of the problem while you do so (to avoid unnecessarily long execution while you debug)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task 3 [30 marks]\n", "\n", "Write a new module containing functions that compute the $n^{th}$ term, $a_n$, in the Fibonacci sequence:\n", " * Iteratively\n", " * Recursively\n", " * Using memoization\n", " \n", "The functions should work starting from any given values of $a_1$ and $a_2$.\n", "\n", "Measure the run-time of each of these functions over a range of values of $n$ and produce a plot to illustrate your results.\n", "\n", "The recursive function implementation gets slow very quickly - I could only do up to $n=48$ on my laptop. Write a recursion relation for the computational complexity of the recursive version of the task. Solve it to prove that the computational complexity grows exponentially with $n$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task 4 [20 marks]\n", "\n", "The computational complexity of the naive divide-and-conquer algorithm for matrix multiplication satisfies the functional equation $$F(n) = 8 F(n/2) + 4 (n/2)^2$$ with $F(1)=1$.\n", "\n", "The corresponding equation for Strassen multiplication is $$F(n) = 7 F(n/2) + 18 (n/2)^2$$ with $F(1)=1$.\n", "\n", "Solve these recurrence relations explicitly to prove that the computational complexity of the two algorithms are $O(n^3)$ and $O(n^{\\log_2(7)})$ respectively. \n", "\n", "It is helpful to adopt the change of variables $n=2^p$ with $a_p = F(2^p)$ to obtain linear (albeit inhomogeneous) recursion relations. \n", "\n", "Some helpful online notes about solving recursion relations can be found at:\n", "\n", "https://www.tutorialspoint.com/discrete_mathematics/discrete_mathematics_recurrence_relation.htm" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Julia 1.8.2", "language": "julia", "name": "julia-1.8" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.8.2" } }, "nbformat": 4, "nbformat_minor": 2 }