Continued fraction/Arithmetic: Difference between revisions

Content added Content deleted
m (use internal links and subscripts)
No edit summary
Line 9: Line 9:
so each may be described by the notation [<math>a_0 ; a_1, a_2, ..., a_n</math>]
so each may be described by the notation [<math>a_0 ; a_1, a_2, ..., a_n</math>]


==[[Continued fraction arithmetic/Continued fraction r2cf%28Rational N%29]]==
Subtasks:
During these tasks I shal use the function described in this task to create continued fractions from rational numbers.
* [[Continued fraction arithmetic/Continued fraction r2cf%28Rational N%29|Create a continued fraction from a rational number]]
==Matrix NG==
* Investigate matrix NG
Consider a matrix NG:
: <math>\begin{bmatrix}
a_12 & a_1 & a_2 & a \\
b_12 & b_1 & b_2 & b
\end{bmatrix}
</math>
and a function G(matrix NG, Number N<sub>1</sub>, Number N<sub>2</sub>)
which returns:
: <math>\frac{a_12*N_1*N_2 + a_1*N_1 + a_2*N_2 + a}{b_12*N_1*N_2 + b_1*N_1 + a_2*N_2 + b}</math>
: Convince yourself that NG = :
: <math>\begin{bmatrix}
0 & 1 & 1 & 0 \\
0 & 0 & 0 & 1
\end{bmatrix}</math> adds N<sub>1</sub> to N<sub>2</sub>
:<math>\begin{bmatrix}
0 & 1 & -1 & 0 \\
0 & 0 & 0 & 1
\end{bmatrix}</math> subtracts N<sub>2</sub> from N<sub>1</sub>
: <math>\begin{bmatrix}
1 & 0 & 0 & 0 \\
0 & 0 & 0 & 1
\end{bmatrix}</math> multiplies N<sub>1</sub> by N<sub>2</sub>
: <math>\begin{bmatrix}
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0
\end{bmatrix}</math> divides N<sub>1</sub> by N<sub>2</sub>
: <math>\begin{bmatrix}
21 & -15 & 28 & -20 \\
0 & 0 & 0 & 1
\end{bmatrix}</math> calculates (3*N<sub>1</sub> + 4) * (7*N<sub>2</sub> - 5)
:Note that with N<sub>1</sub> = 22, N<sub>2</sub> = 7, and NG = :
: <math>\begin{bmatrix}
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0
\end{bmatrix}</math>
:I could define the solution to be N<sub>1</sub> = 1, N<sub>2</sub> = 1 and NG = :
: <math>\begin{bmatrix}
0 & 0 & 0 & 22 \\
0 & 0 & 0 & 7
\end{bmatrix}</math>
:So I can define arithmetic as operations on this matrix which make a<sub>12</sub>, a<sub>1</sub>, a<sub>2</sub>, b<sub>12</sub>, b<sub>1</sub>, b<sub>2</sub> zero and read the answer from a and b. This is more interesting when N<sub>1</sub> and N<sub>2</sub> are continued fractions, which is the subject of the following tasks.



* Investigate G(matrix NG, Contined Fraction N)
* Investigate G(matrix NG, Contined Fraction N)
* The complete solution G(matrix NG, Continued Fraction N<sub>1</sub>, Continued Fraction N<sub>2</sub>)
* The complete solution G(matrix NG, Continued Fraction N<sub>1</sub>, Continued Fraction N<sub>2</sub>)