Answer

问题及解答

Leibniz's formula (Madhava-Leibniz)

Posted by haifeng on 2011-06-21 18:07:54 last update 2020-01-17 07:35:41 | Edit | Answers (4)

\[\frac{\pi}{4}=1-\frac{1}{3}+\frac{1}{5}-\frac{1}{7}+\frac{1}{9}-\cdots\]

1

Posted by haifeng on 2011-06-21 20:08:59

令 $g(x)=\frac{\pi}{4}x$, $x\in[-\pi,\pi]$. 将 $g(x)$ 展成正弦级数, 得到

\[g(x)=\sum_{n=1}^{+\infty}b_n\sin(nx)=\sum_{n=1}^{+\infty}(-1)^{n-1}\frac{\pi}{2n}\sin(nx),\quad x\in(-\pi,\pi)\]

令 $x=\frac{\pi}{2}$, 得到

\[\frac{\pi}{4}=\sum_{n=1}^{+\infty}\frac{(-1)^{k-1}}{2k-1}.\]

2

Posted by haifeng on 2012-07-02 18:11:41

此公式可以用来近似计算 $\pi$, 不过收敛速度很慢, 非常低效. 程序如下

#include 
#include 
#include 

using namespace std;

int main() {
	int s=1;
	double n=1;
	long double t=1,pi=0;

	//fabs(x); Returns the absolute value of x
	while((fabs(t))<1e-9){
		pi+=t;
		n+=2;
		s=-s;
		t=s/n;
	}
	pi*=4;
	cout << \"n=\"<<(unsigned long int)(n) << endl;
	cout << \"pi=\"<

运行结果:

n=1000000001 pi=3.141592652

3

Posted by haifeng on 2020-01-17 07:34:52

此公式也可以用下面的级数导出.

考虑函数 $f(x)=\arctan\frac{1-2x}{1+2x}$, 将它展成 $x$ 的幂级数.

\[
\begin{split}
f'(x)&=\frac{1}{1+\bigl(\frac{1-2x}{1+2x}\bigr)^2}\cdot\frac{-2(1+2x)-(1-2x)2}{(1+2x)^2}\\
&=\frac{-2-4x-2+4x}{(1+2x)^2+(1-2x)^2}\\
&=\frac{-4}{2+8x^2}\\
&=\frac{-2}{1+4x^2}
\end{split}
\]

4

Posted by haifeng on 2020-01-17 07:40:15

利用恒等式

\[
\arctan\frac{1+x}{1-x}=\frac{\pi}{4}+\sum_{n=0}^{\infty}\frac{(-1)^n}{2n+1}x^{2n+1}
\]

这里 $x\in[-1,1]$.

 

参阅问题2409.