This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: MIT OpenCourseWare http://ocw.mit.edu 6.055J / 2.038J The Art of Approximation in Science and Engineering Spring 2008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms . Z Z 6.055J/2.038J (Spring 2008) Solution set 6 Do the following warmups and problems. Due in class on Friday, 09 May 2008 . Open universe: Collaboration, notes, and other sources of information are encouraged. However, avoid looking up answers until you solve the problem (or have tried hard). That policy helps you learn the most from the problems. Bring a photocopy to class on the due date , trade it for a solution set, and figure out or ask me about any confusing points. Your work will be graded lightly: P (made a reasonable effort), D (did not make a reasonable effort), or F (did not turn in). Warmups 1. Integrals Use special cases of a to choose the correct formula for each integral. ∞ 2 a. e − ax dx −∞ ( 1 .) √ π a ( 2 .) √ π/ a Z The most useful special cases here are a → 0 and a → ∞ . When a is zero, the Gaussian becomes the ﬂat line y = 1, which has infinite area. The first choice, √ π a , goes to zero in this limit, so it cannot be right. The second choice, √ π/ a , has the correct behavior. The limit a → ∞ gives the same conclusion: The first choice cannot be right, and the second one might be right. ∞ 1 b. dx a 2 + x 2 −∞ ( 1 .) π a ( 2 .) π/ a ( 3 .) √ π a ( 4 .) √ π/ a The easiest special case is a → ∞ . In that limit, the integrand is zero everywhere, so the integral is zero. The first and third choices are therefore incorrect. To decide between the second and fourth choices, use the special case a = 1. The integral becomes ∞ 1 dx 1 + x 2 −∞ The integral is arctan x . At ∞ it contributes π/ 2, and at −∞ it subtracts − π/ 2, so the integral is π . Only the second choice, π/ a , has the correct behavior. [The problem statement had an error, which one of you found (thank you!): The problem should either have said a ≥ 0 or have used  a  in the candidate answers.] 2 Solution set 6 / 6.055J/2.038J: Art of approximation in science and engineering (Spring 2008) 2. Debugging Use special (i.e. easy) cases of n to decide which of these two C functions correctly computes the sum of the first n odd numbers: int sum_of_odds (int n) { int i, total = 0; for (i=1; i<=2*n+1; i+=2) total += i; return total; } or int sum_of_odds (int n) { int i, total = 0; for (i=1; i<=2*n1; i+=2) total += i; return total; } Special cases are useful in debugging programs. The easiest cases are often n = 0 or n = 1. Let’s try n = 0 first. In the first program, the 2 n + 1 in the loop condition means that i = 1 is the only case, so the total becomes 1. Whereas the sum of the first 0 odd numbers should be zero! So the first program looks suspicious....
View
Full Document
 Spring '08
 SanjoyMahajan
 Fluid Dynamics, special cases

Click to edit the document details