- Assignment 1: due date extended to Tue, Feb
14. . Please read How to Hand in Matlab
Homework.
- Problem 1
- "Normalized" means that d1=1.
1(d): Try a=1 and very small values for b,c
- Problem 2
- Download the files
num2bin.m
(UPDATED) and bin2num.m (note that you have to
put the files where Matlab
can find them). Read IEEE 754 double
precision machine numbers in Matlab.
Note: Even with format long g, different machine
numbers are sometimes displayed in the same way. E.g., x = 1 +
1e-15 is displayed as 1, but typing
num2bin(x) or x-1 shows that it is a
different machine number from 1.
- Problem 3
- 3(a): f(c) = (-b - sqrt(b2 - 4c))/2.
Find a formula for cf = c f'(c)/f(c). Evaluate this
formula in Matlab for b = -y1-y2, c = y1*y2 where y1,y2 are the
values in (i),(ii),(iii).
3(b): The file qeq1.m should look like
this:
function [y1,y2] = qeq1(b,c)
y1 = ... ;
y2 = ... ;
To find the errors of your computed solution use in your main
code
y1 = ... ; y2 = ... ;
b = -y1-y2; c = y1*y2;
[y1hat, y2hat] = qeq1(b,c)
and then compute the relative errors of y1hat,
y2hat compared to y1, y2.
VERY IMPORTANT: Compute b, c from y1 and y2 in
Matlab as shown above, in order to get full machine accuracy.
3(b),(c): Just comment on the numerical stabilty of
the results for
y1 only (not
for y2), since we know from (a) the unavoidable error for
y1.
- Problem 4
- 4(b):To find the relative error of
ytilde:=y1hat-xhat use
|
ahat-bhat| <=
|a/(a-b)| |
ahat | +
|b/(a-b)| |
bhat
|.
4(c): Use the remainder term of the Taylor series to get an
upper bound for |f(x)-f4(x)|/|f(x)|.
4(d): linspace(a,b,n) gives n equidistant numbers
in the interval [a,b] (including the endpoints).