Project Euler 226
Project Euler 226
题目
A Scoop of Blancmange
The blancmange curve is the set of points $(x, y)$ such that $0 \le x \le 1$ and $y = \sum \limits_{n = 0}^{\infty} {\dfrac{s(2^n x)}{2^n}}$, where $s(x)$ is the distance from $x$ to the nearest integer.
The area under the blancmange curve is equal to $\dfrac{1}{2}$, shown in pink in the diagram below.

Let $C$ be the circle with centre $(\dfrac{1}{4},\dfrac{1}{2})$ and radius $\dfrac{1}{4}$, shown in black in the diagram.
What area under the blancmange curve is enclosed by $C$?
Give your answer rounded to eight decimal places in the form $0.abcdefgh$
解决方案
该页面给出了求解牛奶冻曲线积分的递推公式。如果$f(x)=\sum \limits_{n = 0}^{\infty} {\dfrac{s(2^n x)}{2^n}}$,那么有$I(x)$:
为方便计算,我们假设圆$C$和曲线中只有两个交点,其中右交点在$B(0.5,f(0.5))$,左交点通过二分法来求出,假设为为$A(a,f(a))$。
接下来使用该页面的一些公式计算了弓形$\mathop{AB}\limits^{\frown}$的面积,从而计算出弧$\mathop{AB}\limits^{\frown}$竖直向下的那一块面积$S$,也就是说,
最终答案为$I(\dfrac{1}{2})-I(a)-S$。
代码
1 | from math import asin, sin |