跳到主要内容

東京大学 情報理工学系研究科 電子情報学専攻 2026年1月実施 専門 第3問

Author

瑞穂

Description

Recalled statement. (1) Write nonrecursive binary-search pseudocode.

(2) Use it to approximate 2\sqrt2 with error δ<0.01\delta<0.01.

(3) Write recursive binary-search pseudocode.

(4) For rn+1=1+1/(1+rn)r_{n+1}=1+1/(1+r_n), prove

r2n2r2n+1,rn+2rn+1rn+1rn=12rn+3,r_{2n}\le\sqrt2\le r_{2n+1},\qquad \frac{r_{n+2}-r_{n+1}}{r_{n+1}-r_n}=-\frac1{2r_n+3},

and approximate 2\sqrt2 with δ<0.001\delta<0.001.

(5) Apply Newton's method to f(x)=x22f(x)=x^2-2, starting at x=2x=2, to obtain an approximation with δ<0.0001\delta<0.0001.

题目描述

用非递归、递归二分法计算 2\sqrt2,并研究递推 rn+1=1+1/(1+rn)r_{n+1}=1+1/(1+r_n) 的上下界及相邻差比;最后从 x=2x=2 开始使用牛顿法。二分法、递推和牛顿法的误差要求依次为 0.01,0.001,0.00010.01,0.001,0.0001。回忆题缺少递推初值及误差定义。

Kai

Here the numerical error means absolute error. For bisection choose the valid bracket [1,2][1,2]. For (4), the stated ordering holds if 0r020\le r_0\le\sqrt2; the numerical example below chooses r0=1r_0=1. These are explicit conditions of this solution.

(1)

For this root-finding problem, binary search is bisection on the monotone function f(x)=x22f(x)=x^2-2 for x>0x>0.

Bisection(f, left, right, epsilon):
# f(left) <= 0 <= f(right), epsilon > 0
while (right-left)/2 >= epsilon:
middle = (left+right)/2
if f(middle) == 0: return middle
if f(middle) < 0: left = middle
else: right = middle
return (left+right)/2

The root stays inside the bracket, so the returned midpoint has absolute error at most half its width, strictly less than epsilon.

(2)

Starting with [1,2][1,2], the brackets after each update are:

UpdateLeftRight
111.5
21.251.5
31.3751.5
41.3751.4375
51.406251.4375
61.406251.421875

The midpoint is 1.41406251.4140625, with certified error at most 0.0078125<0.010.0078125<0.01.

(3)

BisectionRecursive(f, left, right, epsilon):
middle = (left+right)/2
if (right-left)/2 < epsilon or f(middle) == 0:
return middle
if f(middle) < 0:
return BisectionRecursive(f, middle, right, epsilon)
return BisectionRecursive(f, left, middle, epsilon)

Both versions use O(log((rightleft)/ϵ))O(\log((\text{right}-\text{left})/\epsilon)) iterations. The recursive version additionally uses that many stack frames.

(4)

Let F(x)=1+1/(1+x)F(x)=1+1/(1+x). On x0x\ge0, FF is decreasing and F(2)=2F(\sqrt2)=\sqrt2. Thus a value below 2\sqrt2 is mapped above it, and conversely. Induction from 0r020\le r_0\le\sqrt2 proves

r2n2r2n+1.r_{2n}\le\sqrt2\le r_{2n+1}.

For any u,v1u,v\ne-1,

F(u)F(v)=uv(1+u)(1+v).F(u)-F(v)=-\frac{u-v}{(1+u)(1+v)}.

With u=rn+1u=r_{n+1} and v=rnv=r_n, and using (1+rn)(1+rn+1)=2rn+3(1+r_n)(1+r_{n+1})=2r_n+3, this yields

rn+2rn+1=rn+1rn2rn+3.r_{n+2}-r_{n+1}=-\frac{r_{n+1}-r_n}{2r_n+3}.

The quotient in the question follows when rn+1rnr_{n+1}\ne r_n; at r0=2r_0=\sqrt2 the sequence is constant and the quotient is undefined. For r00r_0\ge0, the consecutive differences contract by a factor at most 1/31/3, establishing convergence to the positive fixed point 2\sqrt2.

For r0=1r_0=1,

r1=32,r2=75,r3=1712,r4=4129,r5=9970.r_1=\frac32,\quad r_2=\frac75,\quad r_3=\frac{17}{12}, \quad r_4=\frac{41}{29},\quad r_5=\frac{99}{70}.

Since r42r5r_4\le\sqrt2\le r_5 and r5r4=1/2030<0.001r_5-r_4=1/2030<0.001, one valid answer is

241291.4137931.\boxed{\sqrt2\simeq\frac{41}{29}\simeq1.4137931}.

The continued fraction associated with this recurrence is 2=1+1/(2+1/(2+))\sqrt2=1+1/(2+1/(2+\cdots)). A continued fraction with every denominator equal to 11 instead has value (1+5)/2(1+\sqrt5)/2.

(5)

Newton's iteration is

xk+1=xkxk222xk=12(xk+2xk).x_{k+1}=x_k-\frac{x_k^2-2}{2x_k} =\frac12\left(x_k+\frac2{x_k}\right).

With x0=2x_0=2,

x1=32,x2=1712,x3=5774081.414215686.x_1=\frac32,\qquad x_2=\frac{17}{12},\qquad x_3=\frac{577}{408}\simeq1.414215686.

Every iterate is at least 2\sqrt2, because

xk+12=(xk2)22xk0.x_{k+1}-\sqrt2=\frac{(x_k-\sqrt2)^2}{2x_k}\ge0.

In particular, x322=1/166464x_3^2-2=1/166464 and

0x32=x322x3+2<1332928<0.0001.0\le x_3-\sqrt2=\frac{x_3^2-2}{x_3+\sqrt2} <\frac1{332928}<0.0001.

Thus 577/408577/408 meets the required accuracy.