22 lines
1.2 KiB
Markdown
22 lines
1.2 KiB
Markdown
|
对比 https://www.bilibili.com/video/BV1Ys3TeFEgi/ 中提到的迭代计算 $\sin$ 函数的算法和使用泰勒展开,意外地发现还是泰勒展开赢麻了……
|
||
|
|
||
|
## 当前结果
|
||
|
在 i5 10400ES 上,通过
|
||
|
```bash
|
||
|
gcc -march=native -O2 -o sin sin.c
|
||
|
```
|
||
|
得到结果为(用时是指循环 10000000 次总耗时,否则都太快了计时误差太大)
|
||
|
```bash
|
||
|
./sin
|
||
|
sin11(0.0001) = 0.9851603975295754, it = 55, dsin=-9.527724023437874e-18, took 0.779344 s.
|
||
|
sin2(0.0001) = 9.999999983333334e-05, it = 2, dsin=8.333333333333334e-23, took 0.064615 s.
|
||
|
sin11(0.5) = 0.9851603975295754, it = 55, dsin=-9.527724023437874e-18, took 0.777089 s.
|
||
|
sin2(0.5) = 0.479425538604203, it = 7, dsin=-2.333729166204778e-17, took 0.285486 s.
|
||
|
sin11(1) = 0.9851603975295754, it = 55, dsin=-9.527724023437874e-18, took 0.775652 s.
|
||
|
sin2(1) = 0.8414709848078965, it = 9, dsin=-8.220635246624331e-18, took 0.417614 s.
|
||
|
sin11(1.3) = 0.9851603975295754, it = 55, dsin=-9.527724023437874e-18, took 0.775861 s.
|
||
|
sin2(1.3) = 0.963558185417193, it = 10, dsin=4.835779466409166e-18, took 0.461802 s.
|
||
|
sin11(1.7) = 0.9851603975295754, it = 55, dsin=-9.527724023437874e-18, took 0.708869 s.
|
||
|
sin2(1.7) = 0.9916648104524686, it = 10, dsin=4.239843809646965e-17, took 0.471206 s.
|
||
|
```
|