Math 753/853 HW1: floating-point numbers

Here's homework 1, due Wednesday Sept 14 midnight. HW1 Julia notebook

A PDF of the Julia notebook is available so you can view the assignment in a browser, without Julia. (HW1 viewable as PDF)

update to HW1, 9/15/2016

Due date: changed to Friday 9/16 at midnight.

Problem 4: The syntax for inputting a 16-bit float is Float16(9.4), not 9.0f0. The latter produces a 32-bit float.

Problem 6: This one's proving challenging for people. Some hints:

How many of the 7s will survive when x = 4778 + 3.77777e-10 is computed in 16 digits? Same for y. Once you have those rounded numbers, how many significant digits will survive in the floating=point computations $x+y$, $x-y$, etc.? If you can't figure this out, go ahead and do the computations in 64 bits and see if you can explain the answers you get.

If you want to compare the 64-bit calculations to something more accurate, use Julia's 256-bit BigFloat type. There are two ways to get a BigFloat.

julia> BigFloat(9.4)
9.400000000000000355271367880050092935562133789062500000000000000000000000000000

julia> big(9.4)
9.400000000000000355271367880050092935562133789062500000000000000000000000000000

Observe, however, that though we have 80 digits of precision in a BigFloat, we've produced 9.4 accurate only to 16 digits. This is because you type 9.4, it's interpreted as a 64-bit float before it's handed off to the BigFloat type. To get an accurate 9.4, you can do this

julia> big(94.0)/big(10.0)^1
9.399999999999999999999999999999999999999999999999999999999999999999999999999945