{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Derivatives \n", "\n", "- Determining Rules\n", "- Examining Relationship between Function and Derivative" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import sympy as sy\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "#writing a derivative and its definition\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Find the Derivative**\n", "\n", "$$f(x) = \\sqrt{x} + x^3$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Derivative at a Point**\n", "\n", "What is $f'(1)$?" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "#instantaneous rate of change of function f\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "#derivative as a function of x\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### Other Functions\n", "\n", "- $\\sin$ and $\\cos$\n", "- $e^x$" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "x, h = sy.symbols('x h')" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "def ddf(f, x, h):\n", " return (f(x + h) - f(x))/h" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "def f(x):\n", " return sy.exp(x)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\frac{- e^{x} + e^{h + x}}{h}$" ], "text/plain": [ "(-exp(x) + exp(h + x))/h" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ddf(f, x, h)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "def g(x):\n", " return sy.sin(x)" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\frac{- \\sin{\\left(x \\right)} + \\sin{\\left(h + x \\right)}}{h}$" ], "text/plain": [ "(-sin(x) + sin(h + x))/h" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ddf(g, x, h)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\cos{\\left(x \\right)}$" ], "text/plain": [ "cos(x)" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.diff(g(x))" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle e^{x}$" ], "text/plain": [ "exp(x)" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sy.diff(f(x))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Desigining a Curve\n", "\n", "- At least 3 zeros between $x = -2$ and $x = 2$\n", "- Plot function and Derivative itself\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": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "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.7.4" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": {}, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 4 }