{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Quiz 1 MCS 471, on Friday 26 August 2021, due 10:50am." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Consider a floating-point system with five places in the fraction\n", "and base 10, with exponents ranging between $-10$ and $+10$.\n", "\n", "1. What is the machine precision in this number system?\n", "\n", "2. Compute $386.04 - 6.8907$ in this number system. Show all steps in your calculation." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## answer to question 1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The machine precision is $10^{-5}$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## answer to question 2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We proceed first by representing the numbers.\n", "\n", "1. $386.04 = +.38604 \\times 10^{+3}$ and $6.8907 = +.68907 \\times 10^{+1}$\n", " \n", "2. Before the subtraction, we denormalize the smallest number.\n", " \n", " $$\n", " \\begin{array}{clcl}\n", " & +.38604 & \\times & 10^{+3} \\\\\n", " - & +.0068907 & \\times & 10^{+3} \\\\ \\hline\n", " & +.3791493 & \\times & 10^{+3}\n", " \\end{array}\n", " $$\n", " \n", "3. The final result is rounded: $+.3791493 \\times 10^{+3} = +.37915 \\times 10^{+3} = 379.15$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The cell below verifies the subtraction of the fractions." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3791493" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "3860400 - 68907" ] } ], "metadata": { "kernelspec": { "display_name": "Julia 1.7.2", "language": "julia", "name": "julia-1.7" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.7.2" }, "latex_envs": { "LaTeX_envs_menu_present": true, "autocomplete": true, "bibliofile": "biblio.bib", "cite_by": "apalike", "current_citInitial": 1, "eqLabelWithNumbers": true, "eqNumInitial": 1, "hotkeys": { "equation": "Ctrl-E", "itemize": "Ctrl-I" }, "labels_anchors": false, "latex_user_defs": false, "report_style_numbering": false, "user_envs_cfg": false } }, "nbformat": 4, "nbformat_minor": 4 }