From d6c61d988bfa4255baf9cdae42db59ebee38363f Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 25 May 2021 17:10:49 +0200 Subject: Added files --- .../.ipynb_checkpoints/Homework4-checkpoint.ipynb | 172 +++++++++++++++++++++ .../Homework4-solutions-checkpoint.ipynb | 61 ++++++++ .../.ipynb_checkpoints/Untitled-checkpoint.ipynb | 6 + 3 files changed, 239 insertions(+) create mode 100644 src/Homework4/.ipynb_checkpoints/Homework4-checkpoint.ipynb create mode 100644 src/Homework4/.ipynb_checkpoints/Homework4-solutions-checkpoint.ipynb create mode 100644 src/Homework4/.ipynb_checkpoints/Untitled-checkpoint.ipynb (limited to 'src/Homework4/.ipynb_checkpoints') diff --git a/src/Homework4/.ipynb_checkpoints/Homework4-checkpoint.ipynb b/src/Homework4/.ipynb_checkpoints/Homework4-checkpoint.ipynb new file mode 100644 index 0000000..47f63cf --- /dev/null +++ b/src/Homework4/.ipynb_checkpoints/Homework4-checkpoint.ipynb @@ -0,0 +1,172 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "*For this exercise you should have received this text in .ipynb format. Complete the exercises by modifying this file, and submit the modified version*\n", + "\n", + "**Deadline:** Sunday, June 6." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Exercise 1 (6 points)**\n", + "\n", + "Use Sage to find the intersection points *in the real plane* (that is, only those points such that *both* coordinates are real numbers) of the following pairs of geometric objects:\n", + "\n", + "* The circle of equation $x^2 + y^2 = 4$ and the ellipse of equation $\\left(\\frac x2\\right)^2 + (2y)^2 = 4$.\n", + "* The circle of equation $x^2 + y^2 = 4$ and the ellipse of equation $\\left(\\frac x2-2\\right)^2 + (2y)^2 = 4$.\n", + "* The curve of equation $y^2 = x^3 -x +1$ and the horizontal line $y=10$.\n", + "* The $x$-axis and the graph of the function $f(x)=\\log(x) - e^{-x}$. *Hint: $f(x)$ has only one real zero.*" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Exercise 2 (6 points)**\n", + "\n", + "(a) Use Sage to compute\n", + "* the derivative\n", + "* a primite (i.e. integral)\n", + "* the power series expansion around $0$ up to order $4$\n", + "\n", + "of the following functions:\n", + "* $f(x) = e^x$\n", + "* $f(x) = \\sin(x)$\n", + "* $f(x) = \\cos(x)$\n", + "* $f(x) = \\tan(x)$\n", + "* $f(x) = \\log(1+x)$\n", + "* $f(x) = \\sqrt[3]{1+x}$\n", + "\n", + "(b) Use Sage to get the Latex code that represents the objects you computed above.\n", + "\n", + "(c) Arrange the results of the previous points in a table in Latex. The table should have 4 columns (function, derivative, integral, series) and one row for each of the functions above. *Note: when including Latex in a Markdown cell in Jupyter you will not receive any warning if you make mistakes; instead the Latex will simply not be rendered and it will appear as plain text. If you have troubles making this work you can send me a separate .tex (and .pdf) file.*" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Compute derivatives etc..." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Compute Latex code" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "(Write your table here)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Exercise 3 (4 points)**\n", + "\n", + "The equation\n", + "\\begin{align*}\n", + "y^2+x^{16}=1\n", + "\\end{align*}\n", + "determines a closed curve in $\\mathbb R^2$ that looks like a rounded square. Determine the area of that shape, giving both an exact value (which might depend on some functions that Sage knows, but you don't) and an approximate value." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Exercise 4 (12 points)**\n", + "\n", + "A team of biologists is monitoring the population of river shrimps in the Alzette. At first they thought that the size $P(t)$ of their population on day $t$ would satisfy the differential equation $P'(t)=P(t)/10$. However this does not work well with the data they have collected, so they now believe that the population of shrimps follows the formula $P'(t)=P(t)/10-b$ for some value of $b$ between 1 and 100. They need your help here.\n", + "\n", + "(a) Using Sage, find a solution for the differential equation with initial conditions\n", + "\\begin{align*}\n", + "\\begin{cases}\n", + "P'(t)&=\\frac{P(t)}{10}-b\\\\\n", + "P(1)&=1000\n", + "\\end{cases}\n", + "\\end{align*}\n", + "where $b$ is a generic constant.\n", + "\n", + "(b) The list `data` in the cell below contains the actual number of shrimps that was measured every day from day $1$ (the $0$ at the beginning is meaningless, but it will help to keep it there). Plot in one single picture, possibly using different colors for each:\n", + "* The data as a bar chart.\n", + "* A curve that interpolates the data, using one of the methods shown in class.\n", + "* The solution of the differential equation for $b=0$.\n", + "* The solution of the differential equation for a value of $b$ of your choice ($1\\leq b\\leq 100$) that fits the data better than $b=0$. *(For this last point there is no right or wrong choice, just pick one that looks good)*" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "data = [0, 1000, 1123, 1223, 1190, 1432, 1553, 1709, 1826, 1980, 2146, 2172, 2383, 2588, 2822, 3401, 3330, 4157, 3994, 4995, 5392, 5910, 6468, 7128, 7325, 7984, 9634, 10473, 11761, 12777]\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Grading**\n", + "\n", + "This homework assignment is worth $28$ ($24+4$) points, distributed as described above.\n", + "\n", + "Your final grade for the course will be the total of points you obtained (notice that the maximum is $20+20+16+28=84$) divided by $4$, rounded to the nearest integer. More precisely\n", + "\n", + "\\begin{align*}\n", + "\\operatorname{grade} = \\operatorname{min}\\left(20, \\left\\lfloor \\frac{\\operatorname{total}}{4} + 0.5\\right\\rfloor\\right)\n", + "\\end{align*}" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SageMath 9.2", + "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.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/src/Homework4/.ipynb_checkpoints/Homework4-solutions-checkpoint.ipynb b/src/Homework4/.ipynb_checkpoints/Homework4-solutions-checkpoint.ipynb new file mode 100644 index 0000000..f8617fd --- /dev/null +++ b/src/Homework4/.ipynb_checkpoints/Homework4-solutions-checkpoint.ipynb @@ -0,0 +1,61 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "f(x) \t Derivative \t Integral \t Series expansion\n", + "e^x \t e^x \t e^x \t 1 + 1*x + 1/2*x^2 + 1/6*x^3 + 1/24*x^4 + Order(x^5)\n", + "sin(x) \t cos(x) \t -cos(x) \t 1*x + (-1/6)*x^3 + Order(x^5)\n", + "cos(x) \t -sin(x) \t sin(x) \t 1 + (-1/2)*x^2 + 1/24*x^4 + Order(x^5)\n", + "tan(x) \t tan(x)^2 + 1 \t log(sec(x)) \t 1*x + 1/3*x^3 + Order(x^5)\n", + "log(x + 1) \t 1/(x + 1) \t (x + 1)*log(x + 1) - x - 1 \t 1*x + (-1/2)*x^2 + 1/3*x^3 + (-1/4)*x^4 + Order(x^5)\n", + "(x + 1)^a \t a*(x + 1)^(a - 1) \t (x + 1)^(a + 1)/(a + 1) \t 1 + (a)*x + (1/2*a^2 - 1/2*a)*x^2 + (1/6*a^3 - 1/2*a^2 + 1/3*a)*x^3 + (1/24*a^4 - 1/4*a^3 + 11/24*a^2 - 1/4*a)*x^4 + Order(x^5)\n" + ] + } + ], + "source": [ + "print(\"f(x)\", \"\\t\", \"Derivative\", \"\\t\", \"Integral\", \"\\t\", \"Series expansion\")\n", + "var('a')\n", + "f(x) = (1+x)^a\n", + "assume(a>0)\n", + "functions = [e^x, sin, cos, tan, log(1+x), f]\n", + "for g in functions:\n", + " print(g(x), \"\\t\", derivative(g(x), x), \"\\t\", integral(g(x),x), \"\\t\", g(x).series(x==0,5))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SageMath 9.2", + "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.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/src/Homework4/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/src/Homework4/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 0000000..7fec515 --- /dev/null +++ b/src/Homework4/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 4 +} -- cgit v1.3