{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# PDE first exercise" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "In this first exercise, we will focus our work on to finite differences and plotting tool." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "First we import our mandatory module" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np # for our mathematics\n", "import matplotlib.pyplot as plt # for plotting" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "We will use the following equation as our reference function and solution:\n", "\n", "$$ f = sin(20x)+exp(-100x)+100*x^2$$" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "In this exercise you have to:\n", "1. make a function to compute $f$\n", "2. make a function which computes the first derivative of $f$ with respect to $x$\n", "3. plot the function and its derivatives for $0\\le x \\le 1$ in a subplot (i.e one plot for $f$ and one plot for its derivative)\n", "\n", "Using a simple `for` loop:\n", "\n", "4. make a function to compute the first derivative of $f$ using a backward difference\n", "5. make a function to compute the first derivative of $f$ using a forward difference\n", "6. make a function to compute the first derivative of $f$ using a centered difference\n", "7. compute the error commited by the different the finite differences and plot them in a subplot\n", "\n", "Finally, replicate the question 4. without using a `for` loop" ] }, { "cell_type": "markdown", "metadata": {}, "source": [] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.9.10 | packaged by conda-forge | (main, Feb 1 2022, 21:27:43) \n[Clang 11.1.0 ]" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "aa75a69a1d963833d899e1aa816ee7deabe3a9171ee005cbd8b95e63a8db26e9" } } }, "nbformat": 4, "nbformat_minor": 2 }