Template:ConvergentCalculator

Use this template to add a row to a table for calculating the convergents of the continued fraction of an irrational square root.

It is called by:
 *  

In order to work out what $p_{k-1}$, $p_{k-2}$, $q_{k-1}$ and $q_{k-2}$ actually are, the table can be built one row at a time.

The previous rows having been built, those values can merely be read off the partly-generated page.

It needs to be called after Template:ConvergentCalculator-Start.

Note that all this template does is evaluate $p_k$, $q_k$ and $\dfrac {p_k} {q_k}$, and pass these and the other parameters to the call to Template:ConvergentTableRow.

The reason for this two-stage process is that you cannot use the  #expr  function within math delimiters, and you appear not to be able to use temporary variables within the context of a Template. Hence when using this technique, all the fields needed to be presented in the actual table are pre-calculated in this template and then passed into a second template, which is designed never to be actually called directly.

For an example of its use, see Continued Fraction Expansion of Irrational Square Root/Example/13/Convergents.