1
$\begingroup$

I am a complete novice in Mathematica so please bear with me. I am trying to graph a sequence that converges to $\pi$ but after $27$ iterations Mathematica just goes crazy and I am not sure why. I got the sequence by first noticing $2^n\sin\frac{\pi}{2^n} \to \pi$ and then just using the double angle formula for cosine. Could some one point out why after 28 iterations Mathematica spits out 0? Also what would be a reasonable way to find how fast by approach converges to pi? Using mathematica? I used Discrete plot but it is hard do see what the error is. I also do not know which tag to use to i apologize if I got it wrong.

Code:

a[n_] := a[n] = Sqrt[2 + a[n - 1]];
a[1] = Sqrt[2];

DiscretePlot[2^n  Sqrt[1 - (2 + a[n - 2])/4], {n, 0, 30}]
$\endgroup$
8
  • $\begingroup$ a[n] convergs to 2. So (2+a[n])/4 is converging to 1. So Sqrt[1-(2+a[n])/4] is converging to Sqrt[1-1]=0. $\endgroup$ – bill s Oct 1 '20 at 15:07
  • $\begingroup$ Change the plotting range DiscretePlot[2^n Sqrt[1 - (2 + a[n - 2])/4], {n, 3, 30}] because a[i] is only defined for ì>=1 $\endgroup$ – Ulrich Neumann Oct 1 '20 at 15:09
  • $\begingroup$ @bills That is correct, but then how do I increase accuracy? Should I move the $2^n$ into the square root? $\endgroup$ – 2132123 Oct 1 '20 at 15:15
  • 1
    $\begingroup$ @UlrichNeumann You are right, but that did not fix the issue $\endgroup$ – 2132123 Oct 1 '20 at 15:36
  • $\begingroup$ Simply specify e.g.; WorkingPrecision -> 100 $\endgroup$ – Daniel Huber Oct 1 '20 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.