{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Homework: Derivatives Intro\n", "\n", "**GOALS**:\n", "\n", "- Explain the definition of the derivative\n", "- Use the definition of the derivative to approximate slopes of tangent lines\n", "- Use the power rule to evaluate derivatives of polynomials\n", "- Use a functions derivative to explain where original function is increasing, decreasing, is maximized, or is minimized. " ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import pandas as pd\n", "import sympy as sy" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### PROBLEM I: Definition\n", "\n", "Below are two definitions of the derivative. In your own words and with pictures, explain what these mean.\n", "\n", "$$\\lim_{h \\to 0} \\frac{f(x + h) - f(x)}{h} \\quad \\text{and} \\quad \\lim_{x_2 \\to x_1} \\frac{f(x_2) - f(x_1)}{x_2 - x_1}$$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### PROBLEM II: Tables\n", "\n", "Using the definition of the derivative below, fill in the tables for appropriate functions at $a = 0$.\n", "\n", "- $f(x) = .5x^3 - 1$\n", "- $g(x) = \\sin(x)$\n", "- $h(x) = \\frac{1}{x}$\n", "\n", "$$\\lim_{h \\to 0} \\frac{f(a + h) - f(a)}{h}$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### PROBLEM III: Equations of Tangent Lines\n", "\n", "For each of the following functions, use the **power rule** to find the derivative $f'(x)$ and write equation for the line tangent to the graph at $x = a$. Draw a picture of $f$ and the tangent line to verify you are correct.\n", "\n", "1. $f(x) = 2x^3 + 4x^2 - 5x - 3$ at $x = -1$.\n", "\n", "2. $f(x) = x^2 + \\frac{4}{x^3} - 10$ at $x = 8$\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### PROBLEM IV: Shapes of curves\n", "\n", "Given the plots of the two derivatives below, identify the following:\n", "\n", "- Intervals where $f$ is increasing\n", "- Intervals where $f$ is decreasing\n", "- Any local maximum or minimum values in $f$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 105, "metadata": {}, "outputs": [], "source": [ "# x = np.linspace(-3, 3, 1000)\n", "# def f(x): return (x + 2)*(x + 1)**2 * x * (x - 1)\n", "# # # set the x-spine (see below for more info on `set_position`)\n", "# fig, ax = plt.subplots()\n", "# ax.spines['left'].set_position('zero')\n", "\n", "# # turn off the right spine/ticks\n", "# ax.spines['right'].set_color('none')\n", "# ax.yaxis.tick_left()\n", "\n", "# # set the y-spine\n", "# ax.spines['bottom'].set_position('zero')\n", "\n", "# # turn off the top spine/ticks\n", "# ax.spines['top'].set_color('none')\n", "# ax.xaxis.tick_bottom()\n", "# ax.plot(x, f(x), label = \"f'(x)\")\n", "# plt.ylim(-5, 5)\n", "# plt.axvline(color = 'black')\n", "# plt.axhline(color = 'black')\n", "# plt.legend(fontsize = 20, frameon = False)\n", "# plt.savefig('images/15_p1.png')" ] }, { "cell_type": "code", "execution_count": 106, "metadata": {}, "outputs": [], "source": [ "# def f(x): return (x - 2)*(x + 2)*(x + 1)*(x - 1)*x**2\n", "# # # set the x-spine (see below for more info on `set_position`)\n", "# fig, ax = plt.subplots()\n", "# ax.spines['left'].set_position('zero')\n", "\n", "# # turn off the right spine/ticks\n", "# ax.spines['right'].set_color('none')\n", "# ax.yaxis.tick_left()\n", "\n", "# # set the y-spine\n", "# ax.spines['bottom'].set_position('zero')\n", "\n", "# # turn off the top spine/ticks\n", "# ax.spines['top'].set_color('none')\n", "# ax.xaxis.tick_bottom()\n", "# def f(x): return (x - 2)*(x + 2)*(x + 1)*(x - 1)*x**2\n", "# ax.plot(x, f(x), label = \"f'(x)\")\n", "# plt.ylim(-8, 5)\n", "# plt.axvline(color = 'black')\n", "# plt.axhline(color = 'black')\n", "# plt.legend(fontsize = 20, frameon = False)\n", "# plt.savefig('images/15_p2.png')" ] } ], "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.7.4" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": {}, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 4 }