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

Content added Content deleted
Line 8: Line 8:


The solutions in C++ and Tcl have different answers to the computation of <math>[1;5,2] - [3;7]</math>, but if you work the sequences out they are the same actual fraction; ''both are correct''. I suspect this is due to differences of rounding semantics with mixed-sign integer division. –[[User:Dkf|Donal Fellows]] 10:22, 11 March 2013 (UTC)
The solutions in C++ and Tcl have different answers to the computation of <math>[1;5,2] - [3;7]</math>, but if you work the sequences out they are the same actual fraction; ''both are correct''. I suspect this is due to differences of rounding semantics with mixed-sign integer division. –[[User:Dkf|Donal Fellows]] 10:22, 11 March 2013 (UTC)

: This depends on the definition of the canonical form for negative numbers. 151/77 is [1;1,24,1,2] so the negative form [-1;-1,-24,-1,-2] seems clearer to me. [[Continued_fraction/Arithmetic/Construct_from_rational_number]] defines how to construct continued fractions thus determine: the integer part; and remainder part, of N<sub>1</sub> divided by N<sub>2</sub>. It then sets N<sub>1</sub> to N<sub>2</sub> and N<sub>2</sub> to the determined remainder part. It then outputs the determined integer part. It does this until abs(N<sub>2</sub>) is zero. Here N<sub>1</sub> is -151 and N<sub>2</sub> is 77. -151/77 is -1 remainder -74. Wikis seem to define the canaonical form as [a<sub>0</sub>;a<sub>i</sub>,...,a<sub>j</sub>] where a<sub>0</sub> is an integer and a<sub>i</sub>,...,a<sub>j</sub> are positive integers. [http://www.andrewduncan.ws/goldenratio/continuedfractions/index.html] gives [-2 ; 25,1,2,1705908949761,1,1,4,2,1,4,1,23…] so your version has some support, but if we adopt it then Mathmatica will have to be rewritten and I think the form which makes the negative form similar to the positive form is better.--[[User:Nigel Galloway|Nigel Galloway]] 13:36, 11 March 2013 (UTC)