taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 1.2.8-2

Exercise 1.2.8-2

not stated yet in Lean solution written

Rating20
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 1.2.8 of Volume 1. Companion chapter: Fibonacci numbers

The task

Use the rounding formula for FnF_n and base-10 logarithms to find the size and the leading digits of F1000F_{1000}.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

Eq. (15) says that FnF_n is ϕn/5\phi^n/\sqrt5 rounded to an integer. The rounding changes the number by less than 1/21/2, so for a number with 200 digits it can be ignored.

Hint 2

Take log⁡10\log_{10} of ϕ1000/5\phi^{1000}/\sqrt5. You need log⁡10ϕ\log_{10}\phi and log⁡105\log_{10}\sqrt5 to about eight digits, because the first is multiplied by 10001000.

Solution

Show the solution

By eq. 1.2.8(15), F1000F_{1000} is ϕ1000/5\phi^{1000}/\sqrt5 rounded to the nearest integer. The error of the rounding is less than 1/21/2, and this changes only the digits far to the right of the 209 digits of the number. So the leading digits come from

log⁡10F1000≈1000log⁡10ϕ−12log⁡105.\log_{10} F_{1000} \approx 1000 \log_{10} \phi - \tfrac12 \log_{10} 5.

The tables give log⁡10ϕ=0.2089876403\log_{10}\phi = 0.2089876403 and log⁡105=0.6989700043\log_{10}5 = 0.6989700043, so 12log⁡105=0.3494850022\tfrac12\log_{10}5 = 0.3494850022. Then

1000⋅0.2089876403−0.3494850022=208.9876403−0.3494850=208.6381553.1000 \cdot 0.2089876403 - 0.3494850022 = 208.9876403 - 0.3494850 = 208.6381553.

The integer part 208208 says that F1000F_{1000} has 209209 digits. The fraction 0.63815530.6381553 is the logarithm of the leading digits: 100.6381553=4.3466…10^{0.6381553} = 4.3466\ldots. Hence

F1000≈4.3466×10208.F_{1000} \approx 4.3466 \times 10^{208}.

Eight digits of log⁡10ϕ\log_{10}\phi are needed: an error of 10−810^{-8} in log⁡10ϕ\log_{10}\phi gives an error of 10−510^{-5} in the logarithm of the answer, which is about 2⋅10−52 \cdot 10^{-5} relative error.

Check

Exact integer arithmetic in python3 gives F1000=43466557686937456435688527675…F_{1000} = 43466557686937456435688527675\ldots, a number with 209209 digits, which is 4.3466558×102084.3466558 \times 10^{208}. The value 100.6381553=4.34665610^{0.6381553} = 4.346656 from the logarithm agrees with it to the accuracy of the tables.

Remarks

The same method gives the size of any FnF_n: the number of digits is ⌊nlog⁡10ϕ−12log⁡105⌋+1\lfloor n \log_{10}\phi - \tfrac12\log_{10}5\rfloor + 1 for n≥2n \ge 2. Exercise 1.2.8-3 prints all numbers F1,…,F1000F_1, \ldots, F_{1000} and needs this size. The proof of eq. (15) is in the C1 chapter on Section 1.2.8.

This solution is checked, and a person has not reviewed it yet. The source.

In Lean

not stated yet The exercise is not stated in Lean yet.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.