{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "7kc9EeLHhORW" }, "source": [ "# Tutorial: Refresher for solving oridinary least squares\n", "\n", "This tutorial and the previous one explore math concepts that will be helpful for understanding the lectures and homeworks. \n", "\n", "## Goals:\n", "* Refresher on derivatives, logarithms and expected values\n", "\n", "This lab draws from [Paul's Math Notes](https://tutorial.math.lamar.edu/pdf/calculus_cheat_sheet_derivatives.pdf)." ] }, { "cell_type": "markdown", "metadata": { "id": "5zLxcLjDuMuo" }, "source": [ "---\n", "# Derivatives" ] }, { "cell_type": "markdown", "metadata": { "id": "ahQqcU9qPPYd" }, "source": [ "## What is a derivative?\n", "\n", "The formal definition of a derivative is: \n", "\n", "$$\\frac{df}{dx} = \\lim_{h \\to 0} \\frac{f(x + h) - f(x)}{h}$$\n", "\n", "The plain language definition of a derivative is something along the lines of, \"How is my function $f$ changing with respect to the variable $x$?\" Put simply, you can think of a derivative as the slope of a function for given values of the variables. \n", "\n", "*See these two videos ([video 1](https://www.youtube.com/watch?v=tt2DGYOi3hc&list=PLmxWmlga0Kgoe-gvtTW4i32Lc_3JI_bEK&index=6), [video 2](https://www.youtube.com/watch?v=50Bda5VKbqA&list=PLmxWmlga0Kgoe-gvtTW4i32Lc_3JI_bEK&index=7)) for a satisfying explanation of how these definitions connect.*\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Examples\n", "\n", "Two quick examples to drive home the idea of what a derivative is: " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**1.** The derivative of $x^2$ is $2x$. Let's plot both of these functions in R. " ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 437 }, "executionInfo": { "elapsed": 524, "status": "ok", "timestamp": 1611522685078, "user": { "displayName": "Patience Stevens", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Gi-_9ZqhIFhAv1oMehJNvNuIKSTyrFQHzjxQKhx=s64", "userId": "01994571539255174942" }, "user_tz": 300 }, "id": "V-vZYT0SswuZ", "outputId": "3af49109-a8e0-4826-8046-2809e9bdd554" }, "outputs": [ { "data": { "text/html": [ "\n", "