{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "useful-jenny",
   "metadata": {},
   "source": [
    "# The Modified Trapezoid Method\n",
    "\n",
    "**Updated April 12**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "acoustic-italian",
   "metadata": {},
   "source": [
    "**Update on April 8:**\n",
    "I recommend first doing this with a fixed number of intervals $n$ rather than an error tolerance, so comparable to the code for the composite trapezoid rule — inded it could use you function from Task 3 for the composite trapezoid rule.\n",
    "\n",
    "Then iteration in pursuit of an error tolerance (doubling $n$ until the estimated error is small enough) could be done as a refinement.\n",
    "This can then by done by my favored approach of:\n",
    "- First, implement with a `for` that does a predetermined number of steps $m$,\n",
    "computing $T_1', T_2', T_4', \\dots, T_{2^m}'$.\n",
    "- Then revise to add an error estimate (e.g the difference between the two most recent approximations) and exit the `for` loop early with a `break` if and when the error estimate is small enough."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "downtown-greenhouse",
   "metadata": {},
   "source": [
    "## A. Write a function based on the **Modified Trapezoid Method**.\n",
    "\n",
    "$$\n",
    "T'_n = T_n - \\frac{f'(b)-f'(a)}{12} h^2,\n",
    "$$\n",
    "\n",
    "to estimate a definite integral with a specified absolute error tolerance.\n",
    "Its input needs a function for the derivative $Df$, along with other input and output as above for the Composite Trapezoid Rule.\n",
    "\n",
    "**Hint:** You already have code for $T_n$, from Task 3."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "several-proportion",
   "metadata": {},
   "source": [
    "## B. The Modified Trapezoid Method, without derivatives"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "through-mentor",
   "metadata": {},
   "source": [
    "Write a new version of the function for the Modified Trapezoid Method, that does not input the derivative.\n",
    "\n",
    "This must therefore use appropriate derivative approximation methods."
   ]
  }
 ],
 "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": 5
}
