{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# MA934 - Week 8 (assessed!) Problem Sheet\n", "\n", "## Deadline: 17:00 (UK time) on Friday 1 December \n", "\n", "For this assignment, you must create a new Jupyter notebook called MA934_Week8_UniID.ipynb to contain the implementations that you write. This should also be exported as a .pdf file such that all execution output (from data to plots) is visible as produced on your own machine. You can separate out individual tasks if you prefer, but the full submission should be made as a single .zip via [our website](/fac/sci/mathsys/courses/msc/ma934/resources/assessedwork/ma934declaration). The platform will not allow you to upload more than one file.\n", "\n", "A few tips:\n", "- please make sure to debug intermediate outputs as you code along. You are welcome to design smaller test cases and toy problems to verify your work (even if they are not part of the final submission).\n", "- consider possible forms of input or arguments and make sure your solution can cope with *interesting* cases.\n", "- do not forget to comment your code and use Markdown cells to explain what you are doing. A perfectly functional solution with no information about the thought process will not receive more than a subset of the points (~$70\\%$ depending on the difficulty of the problem and how transparent the algorithm flow is). \n", "- generally getting used to writing tidy solutions is good practice. Feel free to use [online resources](https://www.ibm.com/docs/en/watson-studio-local/1.2.3?topic=notebooks-markdown-jupyter-cheatsheet) for editing guidance.\n", "\n", "The problems below give you a chance to practice some of the concepts we learned about in week 7, with a focus on the finite difference method and numerical integration." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task 0 - getting up to speed [warm-up, 0 marks]\n", "\n", "In case you have not done so already, please consult the Jupyter notebook on finite difference approximations from Week 7. You can find it [here](/fac/sci/mathsys/courses/msc/ma934/resources/ma934_2324_week2_2_finitedifferences.ipynb). Both standard tests and convergence studies will be useful in what follows." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task 1 - the finite difference method in the real world [50 marks]\n", "\n", "A problem to rekindle our love for physics. Our inital motivation for studying derivative approximation is (partly) grounded in solving real-world problems (in true MathSys spirit). Such an example is provided by solving a variation of the **beam deflection problem**, sketched below (see Chapra, Steven C., and Raymond P. Canale. Numerical methods for Engineers. Vol. 1221. New York: McGraw-Hill, 2011 for details):\n", "\n", "\"array\" \n", "\n", "\n", "We need to define the following parameters (with some sensible starting values in brackets):\n", " * $E$ is the modulus of elasticity ($150$ GPa),\n", " * $I$ is the moment of inertia ($20000$ cm$^4$),\n", " * $w$ is the applied load ($10$ kN/m),\n", " * $L$ is the length of the beam ($10$ m).\n", " \n", "With the above in mind, we want to solve the differential equation\n", "$$EI \\dfrac{d^2 y}{dx^2} = \\dfrac{wLx}{2} - \\dfrac{wx^2}{2}.$$\n", " \n", "Note: you may notice the units above being quite different. Converting everything to a common reference system (e.g. SI units) is highly encouraged (and part of the problem!).\n", "\n", "Here is a suggested solution strategy:\n", "1. Before starting to implement a numerical solution, can you find an analytical solution to the problem to serve as reference result?\n", "2. What finite difference approximation method would you use and why? Write down the chosen technique and implement it once you have given it some thought.\n", "3. Analyse the obtained behaviour and consider varying $h$ (or $\\Delta x$) from just a handful of points to a refined solution until you are satisfied with the quality of your solution. Expand on how you have reached this conclusion." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task 2 - numerical integration of a wave packet [50 marks]\n", "\n", "One of the topics we dedicated considerable attention to during previous weeks was the topic of numerical integration. In what follows we will consider a simplified model function for a **wave packet**, given in the form\n", " \n", "$$f_n(x) = \\exp(-x^2/2)\\cos(nx),$$\n", " \n", "where $n\\in \\mathbb{N}$ is a natural number. We have encountered the first term of this function before in the context of interpolation problems, while the trigonometric term allows useful variation in data that could be encountered in applications related to e.g. signal processing. As an aside, functions of this type are often used to explain concepts such as [group velocity](https://en.wikipedia.org/wiki/Group_velocity) (not a part of this assignment, but perhaps an interesting read).\n", "\n", "Our goal will be to comprehensively study the sensitivity of numerical integration algorithms using the above function, with the following steps provided for guidance: \n", " 1. Conduct a visual inspection of the function behaviour for different values of $n$. What do you expect the result of the numerical integration to be as $n$ is varied? What will your selected integration limits be and why? Use plotting to your advantage and justify each answer using two-three sentences. \n", " 2. Implement the *trapezoidal rule* and *Simpson's rule* and test them on a simpler function of your choice to begin with. Convince yourselves (through ascertaining convergence properties and providing numerical evidence thereof, plotting, and discussion) of the accuracy of the implemented methods as you vary the number of points used to support the integration scheme. \n", " 3. You may also consider using [Boole's rule](https://en.wikipedia.org/wiki/Boole%27s_rule) for added accuracy, but this is not an assessed component of the assignment.\n", " 4. Using your implementations, study the numerical integration result for different values of $n$ and draw suitable conclusions about the accuracy and capabilities of your algorithms. You should aim to cover (and provide insight on) the full problem space as much as possible.\n", " 5. Comment on resource usage efficiency. How would you recommend a user practically tailor the setup of your implementation such that a good balance between accuracy and computational cost is reached? You may think of this as similar to writing a small user guide accompanying your code." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.5" } }, "nbformat": 4, "nbformat_minor": 2 }