Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://reference.wolfram.com/mathematica/ref/Convergents.html" rel="nofollow noreferrer">Convergents</a> of <a href="http://reference.wolfram.com/mathematica/ref/ContinuedFraction.html" rel="nofollow noreferrer">continued fractions</a> offer a useful method for getting better and better fractional representations of an irrational number. I've also found them helpful for understanding connections to other ideas by way of the <a href="http://en.wikipedia.org/wiki/Euclidean_algorithm" rel="nofollow noreferrer">Euclidean algorithm</a>. </p> <p>Let's use convergents to approximate pi and the square root of two.</p> <pre><code>ClearAll[approximate]; approximate[r_, nConvergents_: 8, precision_: 10] := With[{c = Convergents[ContinuedFraction[r, nConvergents]]}, TableForm[Transpose[{c, N[r - c, precision]}], TableHeadings -&gt; {None, {Row[{"approximation of ", r}], "error"}}]] </code></pre> <p>Here's are the first 8 convergents for pi:</p> <pre><code>approximate[Pi] </code></pre> <p><img src="https://i.stack.imgur.com/GehVK.png" alt="approximate pi"></p> <p>Here are the first 8 convergents for <code>Sqrt[2]</code>:</p> <pre><code>approximate[Sqrt[2]] </code></pre> <p><img src="https://i.stack.imgur.com/xJip4.png" alt="approximate root 2"></p> <p>The successive error terms shrink and alternate direction as convergence advances. </p> <p>In <code>approximate</code>, you can optionally specify the number of convergents and precision desired.</p> <p>Enjoy.</p> <hr> <p>Here's some additional <a href="http://search.wolfram.com/?query=continued+fraction&amp;x=0&amp;y=0" rel="nofollow noreferrer">documentation</a> about continued fractions, including some lovely demonstrations.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload