



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; Class: NUMERICAL COMPUTING; Subject: Mathematics; University: Rensselaer Polytechnic Institute; Term: Summer 2010;
Typology: Assignments
1 / 7
This page cannot be seen from the preview
Don't miss anything!
Numerical Computing Summer ’10 MATH/CSCI 4800- Homework-
Assigned Tuesday July 6, 2010 Due Tuesday July 13, 2010
I = (10) 2 = 2^1 = 2.
The fractional part is F = (0.0101101) 2. The overbar notation denotes infinite repetition of the digits under the overbar. Thus, for example,
q = (.1101) 2 = .(1101 1101 1101.. .) 2. (1.1)
Now we can write
F = (.0101101) 2 = y + z
where y = (.010) 2 = 2−^2 = 0. 25 and z = (.0001101) 2 = (2−^3 ) × (.1101) 2 = 2−^3 q where q was defined above in (1.1). To obtain the decimal representation of q, note from (1.1) that
24 q = 1101.1101 = 2^3 + 2^2 + 2^0 + q,
or, 16 q = 13 + q whence q =
With q known, z =
q 8
and then, F = y + z =. 3583333333.... Finally, x = I + F = 2. 3583333333....
The integer part 6 has the binary representation (110) 2. For the fractional part 2/7 the binary repre- sentation is found as follows. Multiply by 2 and record the integer part:
2 7
We see that the pattern has begun to repeat. Therefore the binary representation of 2/7 is
2 7
Combining the results above, 44 7
or, in the standard normalized form,
44 7
Now consider the IEEE single-precision system, which has 24-bit precision, i.e., there are 23 digits following the binary point or radix. Writing out in detail,
x =
where we have included 23 digits following the radix within curly brackets. Now we round to nearest. Since the first digit outside the curly brackets is 0, we simply chop to get
fl(x) = (1.10 010 010 010 010 010 010 010) 2.
In this procedure we have discarded (.010)2−^23. We know from above that (.010) = 2/ 7. Therefore,
fl
Recall that for IEEE single-precision, mach = 2−^23. Therefore for x = 44/ 7 , the relative rounding error is given by (^) ∣ ∣ ∣ ∣
fl(x) − x x
mach.
(a) Solve the equation x^2 − 26 x + 1 = 0 by using the quadratic formula. Use 5-digit decimal arithmetic to find numerical values for the roots; for example, use
168 ≈ 12. 961. Identify any loss-of-significance error that you encounter. (b) Find both roots accurately by using only 5-digit arithmetic.
(d) For high sensitivity the condition number is large. Here, that appears to happen when sin x is near zero. But sin x is the function value, and when that is near zero the relative output error is undefined. In such a case the absolute rather than the relative condition number is relevant. It is given by
Absolute Condition number κA =
Absolute output error Absolute input error
=
sin(x + h) − sin x h
≈ | cos x|.
Since | cos x| ≤ 1 , the condition number is moderate and the problem is well-conditioned.
(a) Write down the expression for P 2 n− 1 (x). (b) How large should n be so that
| sin x − P 2 n− 1 (x)| ≤ 10 −^4
for all −π/ 2 ≤ x ≤ π/2? Check your result by evaluating the resulting P 2 n− 1 (x) at x = π/ 2.
Taylor’s formula with remainder for a function f (x) being expanded about x = x 0 is
f (x) = PN (x) + RN.
Here PN (x), the Taylor polynomial of degree N centered at x 0 , is given by
PN (x) = f (x 0 ) + (x − x 0 )f ′(x 0 ) +
(x − x 0 )^2 2!
f ′′(x 0 ) +
(x − x 0 )^3 3!
f ′′′(x 0 ) + · · · +
(x − x 0 )N N!
f (N^ )(x 0 ),
or, using summation notation, by
PN (x) =
k=
(x − x 0 )k k!
f (k)(x 0 ),
while the remainder is RN =
(x − x 0 )N^ + (N + 1)!
f (N^ +1)(c),
where c lies between x 0 and x but is otherwise unknown.
(a) In the problem under consideration, f (x) = sin x and x 0 = 0. Note that sin x, and all its even-order derivatives, vanish at x = 0, thereby ensuring that the Taylor polynomial of sin x is always of odd degree. Put another way, P 2 n− 1 is the same as P 2 n. Therefore, R 2 n− 1 is the same as R 2 n. Thus we can write
sin x = P 2 n− 1 (x) + R 2 n(x).
It is easily seen that for f (x) = sin x,
f (2p−1)(x) = (−1)p−^1 cos x and hence f (2p−1)(0) = (−1)p−^1.
Therefore
P 2 n− 1 (x) =
∑^ n
p=
x^2 p−^1 (2p − 1)!
f (2p−1)(0)
∑^ n
p=
(−1)p−^1
x^2 p−^1 (2p − 1)!
This is the desired expression for P 2 n− 1. As discussed above, the remainder is
R 2 n =
x^2 n+ (2n + 1)!
f (2n+1)(c) =
x^2 n+ (2n + 1)!
(−1)p+1^ cos c,
where c lies between 0 and x. (b) We need to find n so that the maximum value of R 2 n for x ∈ [−π/ 2 , π/2] does not exceed 10 −^4. Since | cos c| ≤ 1 , we have
|R 2 n| =
x^2 n+ (2n + 1)!
(−1)p+1^ cos c
(π/2)^2 n+ (2n + 1)!
A simple MATLAB calculation (see below) shows that n = 5 is the smallest value of n for which |R 2 n| ≤ 10 −^4.
format short e n=2: n =
2 3 4 5
F=(pi/2).^(2n+1)./factorial(2n+1)
F =
7.9693e-02 4.6818e-03 1.6044e-04 3.5988e- Correspondingly, the Taylor polynomial is
P 9 (x) =
p=
(−1)p−^1 x^2 p−^1 (2p − 1)!
MATLAB shows that P 9 (π/2) = 1. 000003542584286. Since the exact answer for sin(π/2) is 1, the error is 3. 54258 × 10 −^6 < 10 −^4.
(a) Write a MATLAB script to generate the first 20 terms in the sequence defined by the difference equation xk+1 = 111 − (1130 − 3000 /xk− 1 )/xk, with x 1 = 11/ 2 and x 2 = 61/ 11. The exact solution is a monotonically increasing sequence converging to 6. (b) Explain your results, keeping in mind the notions of instability and ill-conditioning. You may wish to explore the effect of small changes in the values of x 1 and/or x 2.
(a) The script and the computed sequence are given below.
x(1)=11/2; x(2)=61/11; for k=2: x(k+1)=111-(1130-3000/x(k-1))/x(k); end
We see that the solution now approaches 100 quite rapidly. This is an indication of the high sensitivity of the solution to initial data, the sign of ill-conditioning.
Thus the mathematical problem is ill-conditioned and the numerical algorithm is unstable.