ödev soru 11
Transcript of ödev soru 11
8/2/2019 ödev soru 11
http://slidepdf.com/reader/full/oedev-soru-11 1/10
Jim Lambers
MAT 460/560
Fall Semester 2009-10Homework Assignment 2 Solution
Section 1.2
3. Suppose p* must approximate p with relative error at most 10-3. Find the largest interval in
which v: must lie for each value of p.
(a) 150
Solution We must have Ip* - 1501/11501 ~ 10-3, or Ip* - 1501 ~ 0.15, which yields the
interval [149.85,150.15].
(b) 900Solution We must have Ip* - 9001 ~ 0.9, which yields [899.1,900.9].
(c ) 1500
Solution We must have Ip* - 15001 ~ 1.5, which yields [1498.5,1501.5].
(d) 90
Solution We must have Ip* - 901 ~ 0.09, which yields [89.91,90.09].
5. Use three-digit rounding arithmetic to perform the following calculations. Compute the ab-
solute error and relative error with the exact value determined to at least five digits.
(a) 133 + 0.921
Solution p =133.921 and p* =134, so the absolute error is 0.079 and the relative error
is 5.90 x 10-4.
(b) 133 - 0.499
Solution p =132.501 and p* =133, so the absolute error is 0.499 and the relative error
is 3.77 x 10-3.
(c ) (121-0.327)-119
Solution p =1.673 and v:relative error is 0.195.
121 - 119 =2, so the absolute error is 0.327 and the
(d) (121 - 119) - 0.327
Solution p =1.673 and p* =1.67, so the absolute error is 0.003 and the relative error
is 1.79 x 10-3.13 6
()14-'7
e 2e-5.4
Solutionp =1.95354 andp* =(0.929-0.857)/(5.44-5.4) =1.80, so the absolute error
is 0.154 and the relative error is 0.0786.
1
8/2/2019 ödev soru 11
http://slidepdf.com/reader/full/oedev-soru-11 2/10
(f ) -WIT + 6e - 632
Solution p =-15.1546 and v: =-31.4 + 16.3 - 0.048 =-15.1, so the absolute error is
0.0546 and the relative error is 3.6 x 10-3.
(g) (~). (~)
Solution p=2/7 =0.285714, and p* =(0.222)(1.29) =0.286, so the absolute error is
2.86 x 10-4, and the relative error is 10-3.
7r-~
(h) -1-7
17
Solution p =-0.0214963 and v: =(3.14 - 3.13)/(1/17) =0, so the absolute error is
0.0215 and the relative error is 1.
9. The first three nonzero terms of the Maclaurin series for the arctangent function are x -
(1/3)x3 + (l/5)x5. Compute the absolute error and relative error in the following approxi-
mations of 7 r using the polynomial in place of the arctangent:
(a) 4 [arctan (~) + arctan G)]
Solution We have
Since the exact value of it,to 15 significant digits, is 3.14159265358979, it follows that the
absolute error is 3.983 x 10-3 and the relative error is (3.983 x 1O-3) / 7 r : : : : : 0 1.268 X 10-3.
(b) 16 arctan (~) - 4 arctan ( 2 ~ 9 )
Solution We have
tt " 16 [~ - (I/:l) G ) \ (1/5) G ) ' ] -
4 [2:~9- (1/3) C : ~ S+ (1/5) C : ~ S ]
: : : : : 0 16 [~ - 3~5 + 15~25] - 4 [2~9 - 4095
1
5757 + 389905~325995]: : : : : 0 3.14162102932503.
Since the exact value of it,to 15 significant digits, is 3.14159265358979, it follows that the
absolute error is 2.838 x 10-5 and the relative error is (2.838 x 1O-5) / 7 r : : : : : 0 9.032 X 10-6.
2
8/2/2019 ödev soru 11
http://slidepdf.com/reader/full/oedev-soru-11 3/10
11. Let
f(x) =xcosx ~ sinx.x - slnx
(a) Find limx---+o(x).
Solution Ifwe substitute x =0, we obtain 0/0, which is an indeterminate form. Using
l'Hospital's Rule three times, we obtain
1. x cos x - sin x
lim f(x) = 1m .x - - - + o x - - - + o X - Slnx
1. cos x - x sin x - cosxIm----------------
x - - - + o 1 - cos x
1. -xsinx. l. F fl . - -- - -- -
x - - - + o 1- cosx
1. - sinx - x cos x.l.Ifl. •
x - - - + o Slnx
1. - cos x - cos x + x sin xIm------------------
x - - - + o cosx
-2.
(b) Use four-digit rounding arithmetic to evaluate f(O.l).
Solution We have
f(O.l)(0.1) cosO.1- sinO.1
0.1 - sin 0.1
(0.1)(0.995) - 0.09983
0.1 - 0.09983
0.0995 - 0.09983
0.00017
-0.00033
0.00017
~ -1.941.
(c) Replace each trigonometric function with its third Maclaurin polynomial, and repeat
part (b).
Solution The third Maclaurin polynomial for cos x is 1 - ~x2, and the third Maclaurin
polynomial for sin x is x - ix3. Substituting these polynomials for cos x and sin x in
f(x), we obtain the function
h(x)x[1-~x2] - [x_ix3]
X - [x - ix3]
3
8/2/2019 ödev soru 11
http://slidepdf.com/reader/full/oedev-soru-11 4/10
(d) The actual value is f(O.l) =-1.99899998. Find the relative error for the values obtainedin parts (b) and (c).
Solution The relative error for the value obtained in part (b) is
while the relative error for the value obtained in part (c) is
1- 2 - (-1.99899998) 1
1- 1.998999981 =0.0005.15. Use the 64-bit long real format to find the decimal equivalent of the following floating-point
machine numbers.
(a) 0 10000001010 1001001100000000000000000000000000000000000000000000
Solution The sign bit s is 0, the exponent c is represented by 10000001010 in binary,
which is 210+ 23+ 21=1024+ 8+ 2=1034 in decimal, and the mantissa f is
1 1 1 1 147f =T1 + T4 + T7 + T8 =2 + 16 + 128 + 256 =256'
Therefore, the value of the floating point number, denoted by x, is
x (_1)S2C-1023(1 + f)
(_1)021034-1023 (1 + 147)256
211403
256
211403
288·403
3224.
(b) 1 10000001010 1001001100000000000000000000000000000000000000000000
Solution This number is identical to the number in part (a), except that the sign bit s
is 1 instead of 0, so the value is -3224.
4
8/2/2019 ödev soru 11
http://slidepdf.com/reader/full/oedev-soru-11 5/10
(c ) 0 0 1 1 1 11 1 1 11 1 0 1 0 10 0 1 1 00 0 0 00 0 0 00 0 0 00 0 0 00 0 0 0 00 0 0 00 0 0 00 0 0 00 0 0 00 0 0 00 0
Solution The sign bit s is 0, the exponent c is given by
9 . 210 - 1" "' 2 '= =1023D 2-1 'i=O
and the mantissa f is
Therefore, the value of the floating point number, denoted by x, is
x (_1)S2C-1023(1 + f)
(_1)021023-1023 (1 + 83)256
339
2561.32421875.
( d ) 0 0 1 1 11 1 1 11 1 1 0 1 0 10 0 1 1 00 0 0 00 0 0 00 0 0 00 0 0 00 0 0 0 00 0 0 00 0 0 00 0 0 00 0 0 00 0 0 00 1
Solution This number is identical to the one in part (c), except that there is an ad-
ditional digit in the mantissa corresponding to 2-52. It follows that the value of this
number, denoted by x, is
x=
1.32421875 +T2
: : : : : 0 1.3242187500000002220446049250313.
17. Suppose two points (xo , YO ) and (Xl, Yl) are on a straight line with Y l # Yo . Two formulas
are available to find the x-intercept of the line:
Y l - Y o
and X =Xo _ (X l - X o )yo .
Y l - Y o
XOYI - X lYOX=
(a) Show that both formulas are algebraically correct.
Solution The equation of the line is
Y l - YoY = (X - X o ) + Yo ·
X l - X o
Setting Y =0 and solving for x, we obtainX l - X o
-y o =X - XoY l - Y o
5
8/2/2019 ödev soru 11
http://slidepdf.com/reader/full/oedev-soru-11 6/10
or(X l - XO )YO
X =Xo - ,YI - Yo
which is precisely the second formula. Ifwe use a common denominator, then we obtain
YI - Yo (X l - XO )YOX 0 "------"-
YI - Yo YI - Yo
XO (YI - Yo ) - (X l - XO )YO
YI - Yo
(XOYI - XOYO ) - (X IYO - XOYO )
YI - Yo
XOYI - X IYO
YI - Yo
which is precisely the first formula.
(b) Use the data (xo ,yo) =(1.31,3.24) and (XI,YI) =(1.93,4.76) and three-digit roundingarithmetic to compute the x-intercept both ways. Which method is better and why?
X =
Solution Using the first formula, we obtain
X =1.31 .4.76 - 1.93 . 3.24
4.76 - 3.24
6.24 - 6.25
1.52
0.00658.
Using the second formula, we obtain
X = 1.31 _ (1.93 - 1.31)3.24
4.76 - 3.24
1.31 _ 0.62 . 3.24
1.52
1.31 _ 2.01
1.52
1.31 - 1.32
-0.01.
The exact value, to three significant digits, is -0.0116, so clearly the second formula is
better. The first formula suffers from catastrophic cancellation in the numerator.
19. The two-by-two linear system
ax + bye,
ex + dy j,
6
8/2/2019 ödev soru 11
http://slidepdf.com/reader/full/oedev-soru-11 7/10
where a, b, c, d , e, f are given, can be solved for x and y a follows:
y
c, provided a
#0;
ad-mb;
f-me;
h
d1'
e - by
set m
x =a
Implement this algorithm using MATLAB and solve the following linear systems.
(a)
1.130x - 6.990y 14.20
8.110x + 12.20y -0.1370
(b)
1.013x - 6.099y 14.22
-18.11x + 112.2y -0.1376
Solution The following function solves the general two-by-two linear system, given the values
of a, b, c, d , e and f.
function [x,yJ=hwlprob 1 2 1 9 ( a,b,c,d,e,f )
% display error message if a is zero
if a==O,
error( ' a must be nonzero' )
end
m=c/a;
dl=d-m*b;
fl=f-m*e;
y=fl/dl;
x=(e-b*y)/a;
In the following MATLAB session, this function is used to solve the systems in parts (a) and
(b).
7
8/2/2019 ödev soru 11
http://slidepdf.com/reader/full/oedev-soru-11 8/10
» [x,yJ=hw 1 pr o b1 2 1 9 ( 1 . 1 3 0 , - 6 . 9 9 0 , 8 . 1 1 0 , 1 2 . 2 0 , 1 4 . 2 0 , - 0 . 1 3 7 0 )
x=
2 . 4 4 4 5 9 1 9 0 4 3 5 1 7 6
y
- 1 . 6 3 6 2 8 1 9 9 5 4 3 3 8 4
» [x,yJ=hw 1 pr o b1 2 1 9 ( 1 . 0 1 3 , - 6 . 0 9 9 , - 1 8 . 1 1 , 1 1 2 . 2 , 1 4 . 2 2 , - 0 . 1 3 7 6 )
x=
4 . 9 7 4 3 8 8 7 5 5 0 6 5 1 9 1 e + 0 0 2
y
8 0 . 2 8 9 4 8 6 9 4 6 7 2 9 5 8
25. The binomial coefficient
(m) m!
k - k !(m - k)!
describes the number of ways of choosing a subset of k objects from a set of m elements.
(a) Suppose decimal machine numbers are of the form
What is the largest value ofmfor which the binomial coefficient ( 7 ) can be computedfor all k by the definition without causing overflow?
Solution The largest number that can be represented in this floating-point system is
0.9999 x 1015=999,900,000,000,000. Using the definition of the binomial coefficient,
overflow will occur if m! is larger than this number. This is the case if m! 2 ': 18, since
18! =6,402,373, 705, 728, 000 and 17! =355,687,428,096,000. Therefore the largest
value ofm for which the binomial coefficient can be computed without causing overflow
is 17.
8
8/2/2019 ödev soru 11
http://slidepdf.com/reader/full/oedev-soru-11 9/10
(b) Show that ( 7 ) can also be computed by
( 7 ) =(7)(7~:). . .(m-:+1).
Solution We have
( 7 )m!
k!(m - k)!
1·2·3· .... (m - 1) . m
(1·2·3· (k - 1) . k)( l ·2·3···· . (m - k - 1) . (m - k))
(1·2·3· (m - k - 1) . (m - k))((m - k + 1) ..... (m - 1) .m)(1·2·3· (k - 1) . k)( l ·2·3···· . (m - k - 1) . (m - k))
(m - k + 1) (m - 1) .m
1·2·3· (k - 1) . k
(7)(7~:). . .(m-:+1).
(c) What is the largest value ofm for which the binomial coefficient ( 7 ) can be computedby the formula in part (b) without causing overflow?
Solution We have
(m ) =mm-1m-2 =m(m-1)(m-2).
3 3 2 1 6
To avoid overflow, this coefficient must not exceed 0.9999 x 1015, which implies that m
must satisfy
m(m - l)(m - 2) ~ 6(0.9999) X 1015 ~ 5.9994 X 1015.
Since m(m - l)(m - 2) ~ m3 for any nonnegative integer m, it follows that the largest
value of m for which the binomial coefficient can be computed is not less than the
largest value of m for which m3 ~ 5.9994 x 1015. This value is (5.9994 x 1015)1/3 : : : : : 0
(1.81706 x 105) : : : : : 0 181, 706.
Ifwe let m=181,706, we obtain m(m-1)(m-2) : : : : : 0 5.9993x 1015. To see if m can be any
larger, we try m=181,707 and obtain m(m-1)(m-2) : : : : : 0 5.9993998 x 1015, so this value
is acceptable as well. However, if we try m =181,708, we obtain m(m - l)(m - 2) : : : : : 0
5.9994988 which is too large, so we conclude that the largest value of m is 181,707.
(d) Use the equation in part (b) and four-digit chopping arithmetic to compute the number
of possible 5-card hands in a 52-card deck. Compute the actual and relative errors.
9
8/2/2019 ödev soru 11
http://slidepdf.com/reader/full/oedev-soru-11 10/10
Solution The number of possible 5-card hands in a 52-card deck is
(52 ) =52 51 504948.
5 543 2 1
Using four-digit chopping arithmetic, we obtain
( 552) : : : : : 0 (1004) (12.75) (16.66) (24.5) (48)
: : : : : 0 (132.6) (16.66) (24.5) (48)
: : : : : 0 (2209) (24.5) (48)
: : : : : 0 (54,120)(48)
: : : : : 0 2,597,000.
The actual value is 2,598,960, so the absolute error is 1,960 and the relative error is
7.541 x 10-4.
10