{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "In this review sheet we consider problems\n", "to prepare for the second midterm exam of mcs 320." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Count the number of points with integer coordinates $(x,y)$\n", "in the region defined by the inequalities $0 \\leq x < 20$, $0 \\leq y < 20$,\n", "$y \\geq x/2$, $y \\leq 3 x$.\n", "\n", "Do the following:\n", "\n", "1. Generate a list L of integer points $(i,j)$ for $i$ and $j$ ranging between 0 and 19.\n", "\n", "2. Select from the list L those points in the cone $y \\geq x/2$ and by $y \\leq 3 x$.\n", "\n", "3. Count the number of points in the cone. Write also the number below." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For some parameter $t$, consider the sequence recursively defined as:\n", "\n", "$F(n) = (1-t) F(n-1) + t F(n-2)$, for $n > 1$, where $F(0) = a$ and $F(1) = b$.\n", " \n", "Using the recursive definition write an efficient SageMath function $F$\n", "to compute $F(n)$ as $F(a,b,t,n)$.\n", "What is the result of $F(a,b,0.3,100)$?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 3" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Consider the function $f(t)$ as the integral of $(1 - e^x)$ for $x$ from 0 to $t$, for $t \\geq 0$. \n", "\n", "1. Define this function in Sage.\n", " \n", "2. What is $f'(1)$?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 4" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The function $g(x,t) = (1-t^2)/(1 - 2xt + t^2)$ is a\n", "generating function for the Chebyshev polynomials.\n", "\n", "1. Compute a Taylor series approximation for $g(x,t)$\n", " around $t = 0$ of order 10. \n", " \n", "2. Select the coefficient of $t^8$ and compare\n", " with the output of ``chebyshev_T(8,x)``.\n", " \n", " Is there a difference between the two?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 5" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Consider the point $(1,1)$ on the curve $f(x,y) = x^2 - y^3 - x + y = 0$.\n", "\n", "1. Give the Sage command(s) to compute a Taylor series about the point $(1,1)$\n", " where the term of the error is of second order.\n", "\n", "2. Compute the slope of the tangent line of the curve at the point $(1,1)$\n", " and use the slope to determine the tangent line.\n", " Write the equation of the tangent line.\n", " \n", " Verify that the tangent line equals the first-order Taylor series at $(1,1)$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 6" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Consider the curve $x^4 - 3 x y + y^4 = 0$. Do the following.\n", "\n", "1. Make a plot for $x$ and $y$ both ranging between $-2$ and $+2$;\n", "\n", "2. Convert the curve into polar coordinates; and\n", "\n", "3. Plot the curve in polar coordinates." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 7" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let $a$ and $b$ be positive numbers.\n", "Consider $f = x^2/a + y/b$ and the unit circle $x^2 + y^2 = 1$.\n", " \n", "Determine the number of candidate extremal values of $f$ on the unit circle.\n", " \n", "Use a lexicographic Groebner basis to compute a triangular form of the equations for this problem." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 8" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Do the following.\n", "\n", "1. Create a 5-by-5 matrix $A$ over the rationals where \n", " the $(i,j)$-the element is $1/(i+j)$ (for $i$ and $j$ both from 1 to 5).\n", "\n", "2. Define $b$ as a vector of length 5 of ones.\n", " Solve the system defined by $A x = b$.\n", " \n", "3. Verify that $b - A x$ equals zero." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 9" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Consider the intial value problem $dy/dt = 2 - 6y$, $y(0) = -1$.\n", "\n", "1. Solve this problem and plot the solution trajectory for $t \\in [0,2]$.\n", " \n", "2. Plot the slope field for $t \\in [0,2]$, $y \\in [-1,0.5]$.\n", " \n", " Place also the particular solution computed the first part of this question on the plot." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Question 10" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Minimize $x+3y$ \n", "\n", "subject to $x \\geq 2$, $y \\geq 1$, $x + 2y \\leq 8$, $x+y \\leq 6$.\n", " \n", "Formulate the linear programming problem and solve it." ] } ], "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" } }, "nbformat": 4, "nbformat_minor": 2 }