Homework #1: MA 402 Mathematics of Scientific Computing Due: Wednesday, January 19

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Homework #1

MA 402
Mathematics of Scientific Computing
Due: Wednesday, January 19

General class expectations for assignments that involve coding:

• You should in general submit two files: one for your writeup (preferably
PDF) and one (or more) containing any code you used (.m or .py).
• Describe the results of your code, including all numerical answers, in the
writeup.

• If the problem involves a short answer (such as the end of Problem 7),
include it in your writeup rather than as a comment in the code file.
• For more involved problems, if you wish to add further explanation about
the methods/algorithms you used, do so in the writeup. With rare ex-
ceptions, avoid copy-pasting large sections of your code into the writeup;
summarize it instead.
• When the code is run (e.g. the green “Run” button in the Matlab editor)
with a clean workspace (clear in Matlab), it should run correctly. Do
not “hard-code” the answers; the code should show how the answers were
obtained to begin with.

In short, your code file is supplementary to the written assignment. A reader


should be able to inspect the code and verify that it works, but should be able
to get the gist of what you did by reading the writeup alone. Consider looking
at the sample project reports on Moodle as a style guide.

1
Problem 1. Fill out the Day 1 Questionnaire, and rate the Hilarious Jokes
(link available on Moodle). The Hilarious Jokes survey contains 42 jokes, so
may take about 20 minutes to fill out depending on how long you savor each
joke. The data will be used as part of one of the class projects later on.
Problem 2. The period T (in seconds) of a pendulum of length L (meters) can
be modeled by the equation s
L
T = 2π ,
g
where g ≈ 9.80665 m/s2 .
a) Suppose that when you time an event using a stopwatch, your recorded
time will be accurate to about ±0.2 seconds. If you time 1 full period of a
pendulum with length L = 1 meter, about how large can you expect the
relative error in your measurement Te to be?
b) How large are the absolute and relative errors in the resulting estimate g̃?
If you expect Te to fall in the interval [T − δT, T + δT ], you can try looking
at the values of g̃ that result from the endpoints T − δT and T + δT .
Include units, when appropriate.
c) How do the previous answers change if you let the pendulum swing for 15
periods instead of just one? Explain why they change the way they do.
d) If you try to conduct this experiment in practice, what do you expect to
happen in the limit as you let the number of periods tend to infinity?
Why?
Problem 3. In the 1965 song New Math, Tom Lehrer solves the problem
(342)8 − (173)8 . What is the solution to this problem, written in base 8? What
is the translation of this problem to base 10?
Problem 4. Exactly how many IEEE double precision floating point numbers
fall in the interval [6, 7] (including the endpoints)? What about [ 12 , 32 ]?

Problem 5. Count to 30 using each of the following methods. Which method


do you find most convenient?
a) On both hands, using a base 6 system.
b) On both hands, using your finger bones for a base 12 system.

c) On one hand, using finger binary.

2
Problem 6. For (a) and (b), express the numbers in IEEE double precision.
For (c), do the reverse.
a) −10.125
b) 230

c) 0 10000000010 10110...0
| {z }
48

Problem 7 (Higham). Consider the recurrence

xk+1 = 111 − (1130 − 3000/xk−1 )/xk , x1 = 11/2, x2 = 61/11.

In exact arithmetic, the xk form a monotonically increasing sequence that con-


verges to 6. Write a Matlab (or Python) script to find the first 35 terms in the
sequence.
You should submit your code and a single scatterplot with the following
features:

• Clearly label the x- and y-axes. All of the labels should have fontsize 18.
• The limits of the y-axis should be [0,110].
• Title the figure “Three-term recurrence”, with fontsize 20.
• The markers should be solid blue squares.

• Add a horizontal black dashed line at the predicted limit of 6, with line-
width 1.5.
• Add a horizontal red dashed line at the observed limit, with line-width
1.5.

• Add a legend with fontsize 18 and appropriate labels.


How does the sequence behave when computed in floating point arithmetic?
Note: this level of detail will be more or less the standard for plots submitted
in assignments and projects this semester. Chapter 7 of the Matlab reference
on Moodle has some sample code that may prove useful.

You might also like