{ "cells": [ { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "LzE4_h_uiPCE" }, "source": [ "# Problem Set I\n", "\n", "You are to either write your completed solution in the solution cell if it is a text based question and code if it is a code question." ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "jd620PQtimbA" }, "source": [ "### Question 1: Addition\n", "\n", "- What kind of number will an even number plus an even number return; even or odd? Why?\n", "- What is the sum of an even number and odd number? Explain.\n" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "qO4F4_QDjMrf" }, "source": [ "### Question 2: Multiplication\n", "\n", "\n", "\n", "* What kind of number will an even number times an even number return? Explain.\n", "* Odd times Odd?\n", "- Even times Odd?\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "lTnqGl94jfpa" }, "source": [ "### Question 3: Descartes\n", "\n", "Read through the first 10 pages of Descartes Geometry [here](https://archive.org/details/TheGeometry/page/n13). Your goal is to first understand his visual approach to multiplication and square root extraction. Use his approach to demonstrate:\n", "\n", "- Construction of $3 \\times 4$\n", "- Construction of $\\sqrt{7}$ ([here](https://www.maa.org/press/periodicals/convergence/descartes-method-for-constructing-roots-of-polynomials-with-simple-curves-history-of-constructing) is an extra visual for this)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "MOTcWdpLnG5R" }, "source": [ "### Question 4: Babylonian Algorithm for Square Root\n", "\n", "Read the Wikipedia entry on the Babylonian square root algorithm [here](https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method). Why is it so that \"if x is an overestimate to the square root of a non-negative real number S then $\\frac{S}{x}$ is an underestimate\"? How do we use this to approximate $\\sqrt{2}$?\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "tgSTNy3an0GU" }, "source": [ "### Question 5: Functions with Python\n", "\n", "Make sure you have reviewed the earlier videos. Use these and the example code below to answer the following questions.\n", "\n", "1. Represent the functions described in words below in symbols, tables, and plots using Python. For your tables, you will make a `DataFrame` with `Pandas`, for your symbolic representation you should use LaTeX in a text cell, and for your graph you should use `matplotlib`.\n", "\n", "- Input a number and return its square.\n", " - Domain for table is $x \\in [-2, -1, 0, 1, 2]$\n", " - Domain for plot is $-5 \\leq x \\leq 5$\n", " \n", "- Input an angle and return the sin of the angle\n", " - Domain for table is $x \\in [-\\pi, -\\pi/2, 0, \\pi/2, \\pi]$\n", " - Domain for plot is $4\\pi \\leq x \\leq 4\\pi$\n", "\n", "- Input a number and return two to the power of that number\n", " - Domain for table is $x \\in [-2, -1, 0, 1, 2]$\n", " - Domain for plot is $-5 \\leq x \\leq 5$\n", " \n", " " ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "colab": {}, "colab_type": "code", "id": "tORinTnZikRc" }, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "#domain from -5 to 5 -- 1000 points\n", "x = np.linspace(-5, 5, 1000)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "#define function f\n", "def f(x):\n", " return x**2" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "16" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#evaluate f at x = 4\n", "f(4)" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "#evaluate f at all x's in x\n", "y = f(x)" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "#table of values\n", "f_table = pd.DataFrame({'x': x, 'f(x)': y})" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | x | \n", "f(x) | \n", "
|---|---|---|
| 0 | \n", "-5.00000 | \n", "25.000000 | \n", "
| 1 | \n", "-4.98999 | \n", "24.900000 | \n", "
| 2 | \n", "-4.97998 | \n", "24.800201 | \n", "
| 3 | \n", "-4.96997 | \n", "24.700602 | \n", "
| 4 | \n", "-4.95996 | \n", "24.601203 | \n", "