She then plans to compute a34 by calculating the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Solutions Name (b) [5 points] Mal decides to use the technique from part (a) to compute the value B = A1/4 . She then plans to compute A3/4 by calculating the value C = B 3 = B ·B ·B . Provide an explanation of why this technique does not work. Hint: Define α to be the fractional part of A1/4 , so that B = A1/4 − α. What happens when you compute C = B 3 ? Solution: When you expand out the formula for C , you get C = B 3 = (A1/4 − α)3 = A3/4 − 3A2/4 α + 3A1/4 α2 − α3 . If A is large, then γ = 3A2/4 α − 3A1/4 α2 + α3 will be significantly greater than 1, and so we’ll have C = A3/4 − γ with γ > 1. Hence, C will not be A3/4 . (c) [5 points] Mal clearly needs a way to check her answer for A3/4 , using only integers. Given a pair of positive integers A and C , explain how to check whether C ≤ A3/4 using O(1) additions, subtractions, multiplications, and comparisons. Solution: The equation C ≤ A3/4 is equivalent to the equation C 4 ≤ A3 , which is equivalent to C · C · C · C ≤ A · A ...
View Full Document

This document was uploaded on 03/17/2014 for the course ELECTRICAL 6.006 at MIT.

Ask a homework question - tutors are online