Continued fraction/Arithmetic/G(matrix ng, continued fraction n1, continued fraction n2): Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
No edit summary
Line 40: Line 40:
a_{12} & a_{12} & a_2 & a_2 \\
a_{12} & a_{12} & a_2 & a_2 \\
b_{12} & b_{12} & b_2 & b_2
b_{12} & b_{12} & b_2 & b_2
\end{bmatrix}</math>

When I output a term t I change my internal state:
: <math>\begin{bmatrix}
a_{12} & a_1 & a_2 & a \\
b_{12} & b_1 & b_2 & b \end{bmatrix}</math> is transposed thus <math>\begin{bmatrix}
b_{12} & b_1 & b_2 & b \\
a_{12}-b_{12}*t & a_1-b_1*t & a_2-b_2*t & a-b*t
\end{bmatrix}</math>
\end{bmatrix}</math>

Revision as of 12:15, 12 February 2013

This task performs the basic mathematical functions on 2 continued fractions. This requires the full version of matrix NG:

I may perform perform the following operations:

Input the next term of continued fraction N1
Input the next term of continued fraction N2
Output a term of the continued fraction resulting from the operation.

I output a term if the integer parts of and and and are equal. Otherwise I input a term from continued fraction N1 or continued fraction N2. If I need a term from N but N has no more terms I inject .

When I input a term t from continued fraction N1 I change my internal state:

is transposed thus

When I need a term from exhausted continued fraction N1 I change my internal state:

is transposed thus

When I input a term t from continued fraction N2 I change my internal state:

is transposed thus

When I need a term from exhausted continued fraction N2 I change my internal state:

is transposed thus

When I output a term t I change my internal state:

is transposed thus