{ "cells": [ { "cell_type": "markdown", "id": "bf20212a-80f7-4066-a70e-58dea3f35a38", "metadata": {}, "source": [ "Submit your answers to gradescope before, or at 3:40pm." ] }, { "cell_type": "markdown", "id": "e8cfd805-36b2-41f9-a7c6-64d881bdec40", "metadata": {}, "source": [ "# Question 1" ] }, { "cell_type": "markdown", "id": "03aceab3-b08f-47cb-82c0-b39d11a5bee0", "metadata": {}, "source": [ "Let $N = \\exp(\\sqrt{5})$.\n", "\n", "1. Compute a rational approximation for $N$, accurate to 32 decimal places.\n", "\n", "2. Verify the accuracy of your rational approximation by computing the relative error." ] }, { "cell_type": "markdown", "id": "a483fc53-d094-4713-a7ce-fdfada77588b", "metadata": {}, "source": [ "# Question 2" ] }, { "cell_type": "markdown", "id": "fcc284b9-b3b2-4adc-8166-636a1c33f4f5", "metadata": {}, "source": [ "Consider the finite field with 7 elements.\n", "\n", "Show that $p = x^3 + 3 x^2 + 6$ is irreducible over this field.\n", "\n", "Declare $\\alpha$ as a formal root of $p$.\n", "What is $\\alpha^7$ in this finite field extension?" ] }, { "cell_type": "markdown", "id": "e0a6bc5d-b7ea-493f-bed7-9920fb512333", "metadata": {}, "source": [ "# Question 3" ] }, { "cell_type": "markdown", "id": "26124e9f-4afa-4105-9a0b-0c24765934eb", "metadata": {}, "source": [ "Compute a numeric factorization of $p = x^4 + 3 x^2 + x - 1$.\n", "\n", "Expand the factorization and compare the coefficients of the expanded form\n", "with the coefficients of $p$. \n", "\n", "What is the largest error on the coefficients?" ] }, { "cell_type": "markdown", "id": "3f81a6c5-9c1c-4035-b199-22a29bc9875a", "metadata": {}, "source": [ "# Question 4" ] }, { "cell_type": "markdown", "id": "bf572878-6f86-47fd-ae4f-53cec12d625f", "metadata": {}, "source": [ "Draw the binary expression tree defined by the fast callable object for\n", "\n", "$$\n", " (\\cos(b) - \\sin(c^2) + 2)/(b c - 2 a).\n", "$$" ] }, { "cell_type": "markdown", "id": "60c1573b-36ca-4211-a289-0abd8390a45b", "metadata": {}, "source": [ "# Question 5" ] }, { "cell_type": "markdown", "id": "139dd403-48c5-45f9-926a-c62830122fe6", "metadata": {}, "source": [ "What does the preparser in SageMath do?\n", "\n", "Give an application of `preparse(x)`, with a good example \n", "for its argument `x`." ] }, { "cell_type": "markdown", "id": "36574236-42ec-4633-a58a-b031d9eb2f8a", "metadata": {}, "source": [ "# Question 6" ] }, { "cell_type": "markdown", "id": "194efe90-95c8-4221-a113-48adf8d36076", "metadata": {}, "source": [ "The\n", "``f = lambda n: float(sum([(k/n)*exp(k/n) for k in range(1,n)])/n)``\n", "\n", "computes the right hand side of\n", "$$\n", " \\qquad \\int_0^1 x e^x dx \\approx \\frac{1}{n} \n", " \\sum_{k=1}^{n-1} \\left( \\frac{k}{n} \\right) \\exp\\left( \\frac{k}{n} \\right).\n", "$$\n", "\n", "1. Time the execution of `f` for $n = 10000$.\n", " \n", " Explain why `f` is inefficient.\n", "\n", "2. Apply vectorization to improve the efficiency. Verify the correctness.\n", "\n", " Time the execution of the vectorized function for $n = 10000$, compare with timings of `f`." ] }, { "cell_type": "markdown", "id": "6e022353-3cab-4db2-9db7-82ec1c9e34d3", "metadata": {}, "source": [ "# Question 7" ] }, { "cell_type": "markdown", "id": "9ca487b5-1e50-4fd2-96fc-bc533162709c", "metadata": {}, "source": [ "Let $q = (x^6 - 3 x^4 + 2 x + 1)/(x^6 + 2 x^5 - 3 x^4 + 3 x + 7)$.\n", "\n", "Compute a partial fraction decomposition of $q$ \n", "over the complex numbers.\n", "\n", "How many operations does it takes to evaluate $q$ compared\n", "the number of operations to evaluate its partial fraction decomposition?" ] }, { "cell_type": "markdown", "id": "4812edc4-e8c4-49d1-94ee-18bbd7c0c103", "metadata": {}, "source": [ "# Question 8" ] }, { "cell_type": "markdown", "id": "eea59726-9a68-4319-b3bf-c0301676f7ff", "metadata": {}, "source": [ "Transform\n", " $\\displaystyle (x-y)^4 + \\frac{(x+y)^3}{(x-y)^2}$\n", " into $\\displaystyle \\frac{(x-y)^6 + (x+y)^3}{(x-y)^2}$,\n", " without retyping." ] }, { "cell_type": "markdown", "id": "08631d7c-dc8f-4ff3-874b-50a4827bf323", "metadata": {}, "source": [ "# Question 9" ] }, { "cell_type": "markdown", "id": "ce87a84b-5368-4300-863b-26998c55947d", "metadata": {}, "source": [ "Are the expressions $\\displaystyle p = \\frac{x^2 + 7 x - 8}{x - 1}$ and $q = x + 8$ the same?\n", "\n", "Justify your answer by appropriate *symbolic* computations.\n", "\n", "Demonstrate the application of a *numerical* probability-one equality test." ] } ], "metadata": { "kernelspec": { "display_name": "SageMath 10.3", "language": "sage", "name": "sagemath" }, "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.10.14" } }, "nbformat": 4, "nbformat_minor": 5 }