2
$\begingroup$

I am trying to compare the accuracy of a finite series and product version of the $\sin(x)$ function.

I have $$\sin() = \prod_{=1}^n \left[1 − \left(\frac{}{\pi}\right)^2\right]$$ for the product function. And, $$\sin() = \sum_{k=0}^n \frac{(−1)^\cdot ^{2+1}}{(2+1)!} $$

for the series function, where $n$ in both cases is a finite value.

I put these two functions in code and compared them to a calculators sine function. It seems like the series functions requires way less terms in order to reach simple accuracy to the calculators version. While the product, took many or close to infinite terms to reach an accuracy that satisfied close to the sine function.

My question is, why is this the case? Why is the product version of sine not as accurate in comparison to the series version. Or did I make a mistake, possibly in code?

  • 0
    I think your calculates be about $0$ and if you compare accuracy about $1$ or $\dfrac{\pi}{2}$, the result will be contrary.2017-02-09
  • 2
    Both are exactly accurate, if you take infinitely many terms. Also, neither of them is designed for practical calculations. Also, follow the advice by MyGlasses: take $z=10\pi+0.00001$ and see what happens.2017-02-09
  • 1
    you should really replace equalities by approximates into your formulas2017-02-09

1 Answers 1

3

For simplicity, Let $\,z=1\,$, and define: $$ \begin{align} &\, f_{\small p}(n) =\prod_{=1}^{n}\left(1−\frac{1}{\pi^2\,^2}\right) \quad\&\quad f_{\small s}(n) =\sum_{k=0}^n\frac{(−1)^}{(2+1)!} \\[2mm] &\, \color{blue}{\Delta\,f_{\small p}(n)}=|f_{\small p}(n)-f_{\small p}(n-1)|=\frac{1}{\pi^2\,n^2}\,\prod_{=1}^{n-1}\left(1−\frac{1}{\pi^2\,^2}\right) \approx\color{blue}{\frac{1}{(\pi\,n)^2}} \\[2mm] &\, \color{red}{\Delta\,f_{\small s}(n)}=|f_{\small s}(n)-f_{\small s}(n-1)|=\frac{1}{(2n+1)!} \approx\color{red}{\frac{1}{(2\,n)!}} \end{align} $$ If $\,n=10\,$, Then: $$ \Delta\,f_{\small p}(10)=\frac{1}{(\pi\times10)^2}\approx\frac{1}{10^{3}} \quad\&\quad \Delta\,f_{\small s}(10)=\frac{1}{20!}\approx\frac{1}{10^{18}} $$ Generally, the convergent speed of the sin product formula is of order $\,\mathcal{O}\left(1/N^{2}\right)\,$, which is away slower than the convergent speed of summation formula with order $\,\mathcal{O}\left(1/(2N)!\right)\,$. $$ \begin{align} \sin(1)\qquad &=\,0.8414709848078965 \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad \\[2mm] \prod_{=1}^{10}\left(1−\frac{1}{\pi^2\,^2}\right) &=\,0.84\color{red}{9}6252504108276 \\ \sum_{k=0}^{10}\frac{(−1)^}{(2+1)!}\quad &= \, 0.841470984807896\color{red}{6} \end{align} $$