

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Assignment; Professor: McNelis; Class: Intro Scientific Comp; Subject: Computer Science; University: Western Carolina University; Term: Unknown 1989;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!
CS 340 – Introduction to Scientific Computing Homework Project # 4: Computer Arithmetic
Purpose of the Project: This project was designed to make sure each student is comfortable with IEEE floating point numbers and computer arithmetic, as well as potential errors associated with floating point arithmetic in limited preci- sion environments.
You are required to write your solutions to this homework in LATEX. You are to submit the electronic portions of your homework (the .tex file, the .pdf file, and the graphics files) via WebCAT.
(a) [4 points] Determine the value for “shift” here. Explain your reasoning. (b) [6 points] Use a graphics package to draw a number line, and plot and label all of the positive machine numbers representable with this machine on it. (Hint: you may want to color code them for your own use, with one color for each c value.) Give the illustration here. (c) [6 points] If you were allowed access to 3 additional bits to represent each number, and you knew you needed to represent much smaller (in magnitude) numbers than what you’ve listed above, give TWO ways in which you would change your number representation (in bits and/or formula) to achieve this. Explain your reasoning.
(−1)s^2 c−^3 (1 + f )
Suppose that was the “short form” representation for machine numbers on the Mini-Machine, and there’s also a “long form” available that utilizes twice as many bits to represent a number. With the long form, the bits are distributed in the following fashion: 1 bit to represent the sign, 5 bits to represent the exponent, and 6 bits to represent the fraction. The long form of the floating point number is then given by (−1)s^2 c−^15 (1 + f )
(a) [5 points] Explain why all of the short form numbers can be represented in the long form. (b) [5 points] Find machine epsilon if the long format is our most precise representation of num- bers? (c) [5 points] How many long form floating point numbers are there between any two adjacent short form floating point numbers? Explain your reasoning. (You really don’t want to enumerate these. There are at least two ways to come up without enumerating them.) (d) The following machine number is given in the “long format”.
1 1 0 1 1 1 0 1 1 1 0 1 i. [3 points] Determine it’s base 10 (decimal) equivalent. Show your calculations. ii. [4 points] Find the next largest and smallest machine numbers, and represent these in their “long format” as well as with their decimal equivalent. Label your answers accordingly.
x = 192. 4031 , y = 0. 00605008 , z = 192. 2758
(a) x ∗ y (b) x − z (c)
z y
x =
−b ±
b^2 − 4 ac 2 a to approximate the solutions to the quadratic equation given by
You do NOT have to show all of your steps. (b) [4 points] Compute the absolute and relative errors of each result, taking the true solutions to be 1971.605916 and 0.05077069387. (c) [5 points] Explain any surprising results, and make a suggestion on how to rearrange the calcu- lation of the quadratic formula to improve your results.
x tan x cos x − 1
x sin x cos^2 x − cos x
x(sin(x) + tan(x)) sin^2 x
(x sin x + x tan x) cos(2x) − 1
are equal when they are defined.
(a) [9 points] Use calculus to evaluate lim x→ 0
x tan x cos x − 1
. Show all of your work! (L’Hopital’s Rule!!)
(b) [6 points] Use Excel (or any spreadsheet) to evaluate these expressions for x = 2−k^ for k = 1 , 2 , · · · , 30. Make sure you have at least six columns: one for k values, one for the x values, and one column each for expressions A, B, C, and D. Make sure that you display each result to 10 decimal places and have adequate space to display these digits. Turn in a copy of this spreadsheet, saved as XGoesToZero.xls. (c) [8 points] Does Excel produce the same result for expressions A, B, C and D for all values of x here? If not, which formula is more reliable? Explain your reasoning thoroughly in terms of the stability of computer arithmetic.