The Art and Science of C 阅读笔记 II

对数学(尤其是大学高等数学)有恐惧心理的请略过吧…

Algorithms (算法) 这一章有个运用泰勒公式(Taylor Series)求平方根(square root)的程序。虽然C语言的math.h库里已经有个sqrt的function了,不过这个sqrt function本身怎么写呢? 大学微积分里的泰勒公式终于派上用途了…我正好忘的一干二净了:)

先来学习/温习下泰勒公式吧:
taylor series

后面的Rn(x) 是拉格朗日余项,当|x-x0|无穷小时,可以去掉拉格朗日余项,近似认为f(x) 等于前面的n项之和。

要求的是f(x) = √x,根据求导公式f'(X) = c Xc-1,得出f'(x0) = 1/2 x-1/2,二阶,三阶…N阶导以此类推。假设x0 = 1,则f(1) = 1, f'(1) = 1/2, f''(1) = - 1/4, f'''(1) = 3/8 ...
Read More

You Might Know

This site is powered by WordPress CMS & hosted by Dreamhustle Dreamhost.

And the theme is inspired by WP Typo and completely crafted under Gentoo Linux with VIM editor.

Sponsors

Monthly Archives

Search