Napište funkci, která počítá rozvoj funkce 1 1 + x {\displaystyle 1 \over {\sqrt {1+x}}} pro − 1 < x ≤ 1. {\displaystyle -1<x\leq 1.}
1 1 + x = 1 − 1 2 x + 1 ⋅ 3 2 ⋅ 4 x 2 − 1 ⋅ 3 ⋅ 5 2 ⋅ 4 ⋅ 6 x 3 + 1 ⋅ 3 ⋅ 5 ⋅ 7 2 ⋅ 4 ⋅ 6 ⋅ 8 x 4 − … {\displaystyle {1 \over {\sqrt {1+x}}}=1-{1 \over 2}x+{{1\cdot 3} \over {2\cdot 4}}x^{2}-{{1\cdot 3\cdot 5} \over {2\cdot 4\cdot 6}}x^{3}+{{1\cdot 3\cdot 5\cdot 7} \over {2\cdot 4\cdot 6\cdot 8}}x^{4}-\ldots }
Zkontrolujte s využitím standardní funkce std::sqrt(double).
Spolu s relativní chybou výsledku vypište také počet potřebných iterací. Přičemž tento počet nesmí přesáhnout hodnotu 1e+5.
[ Zpět | C++ ]