# 题目

Problem 587. Concave triangle

A square is drawn around a circle as shown in the diagram below on the left.
We shall call the blue shaded region the L-section.
A line is drawn from the bottom left of the square to the top right as shown in the diagram on the right.
We shall call the orange shaded region a concave triangle.

It should be clear that the concave triangle occupies exactly half of the L-section.

Two circles are placed next to each other horizontally, a rectangle is drawn around both circles, and a line is drawn from the bottom left to the top right as shown in the diagram below.

This time the concave triangle occupies approximately 36.46% of the L-section.

If n circles are placed next to each other horizontally, a rectangle is drawn around the n circles, and a line is drawn from the bottom left to the top right, then it can be shown that the least value of n for which the concave triangle occupies less than 10% of the L-section is n = 15.

What is the least value of n for which the concave triangle occupies less than 0.1% of the L-section?

# 分析

• 第 1 个圆的方程：
• 圆弧 DC 的方程：
• 点 D 的坐标：
• 令 x 为点 D 的横坐标，三角形 ABD 的面积：
• 凹三角形 BCD 的面积：由与圆弧 DC 相关的定积分计算。
• L 形区域的面积：(S正方形 - S) / 4 = (4-π)/4 = 1 - π/4

# 解答

``````main = print \$ until (\n -> let x = n / (n + sqrt(2*n) + 1)
in (f 1 - f x + x*x/n/2) / (1 - pi/4) < 0.001) succ 1
where f x = x - ((x-1) * sqrt(x*(2-x)) + asin(x-1)) / 2
``````

• 第 1 行的`x`就是点 D 的横坐标。
• 第 3 行的函数 f 就是圆弧 DC 的不定积分。
• 第 2 行的`f 1 - f x`就是使用定积分计算凹三角形 BCD 的面积。
• 第 2 行的`x*x/n/2`就是三角形 ABD 的面积。
• 第 2 行的`1 - pi/4`就是 L 形区域的面积。
• 第 1 行的`until`函数从 1 开始依次递增`n`值，直到计算出所求比例小于 0.1%。

# 初等数学

• 点 D 的坐标：
• 圆心角：
• 弓形面积：
• 三角形 ACD 面积：

``````main = print \$ until (\n -> let
h = 1 / (n + sqrt(2*n) + 1); θ = 2 * asin(sqrt(h/2))
in (h - θ + sin θ) / 2 / (1 - pi/4) < 0.001) succ 1
``````

# 数值积分

intnum(X=a,b,expr,{tab}): numerical integration of expr from a to b with respect to X. Plus/minus infinity is coded as +oo/-oo. Finally tab is either omitted (let the program choose the integration step), a non-negative integer m (divide integration step by 2^m), or data precomputed with intnuminit.

``````f(n)=b=n/(n+sqrt(2*n)+1);(intnum(x=b,1,1-sqrt(2*x-x*x))+b*b/n/2)/(1-Pi/4)
n=1;while(f(n)>=0.001,n++);print(n);quit()
``````