rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

continued fractions: sign of sqrt terms ignored #1028

Open rtoy opened 2 weeks ago

rtoy commented 2 weeks ago

Imported from SourceForge on 2024-07-03 22:27:45 Created by robert_dodier on 2007-01-14 04:53:51 Original: https://sourceforge.net/p/maxima/bugs/1062


cflength : 4; cf(sqrt(2) - 1); => [0, 2, 2, 2, 2] /* OK */ cf(sqrt(2) - 2); => [0, - 1, - 1, - 2, - 2, - 2] /* OK (but not canonicalized) */ cf(1 - sqrt(2)); => [2, 2, 2, 2, 2] /* WRONG */ cf(1 + sqrt(2)); => [2, 2, 2, 2, 2] /* OK */ cf(2 - sqrt(2)); => [3, 2, 2, 2, 2] /* WRONG */ cf(2 + sqrt(2)); => [3, 2, 2, 2, 2] /* OK */

cf ignores the minus sign on sqrt (i.e. treats -sqrt(foo) the same as +sqrt(foo)), as shown in the above examples. cf thinks minus signs are OK if not attached to sqrt.

rtoy commented 2 weeks ago

Imported from SourceForge on 2024-07-03 22:27:46 Created by jfmertens on 2011-07-05 18:31:15 Original: https://sourceforge.net/p/maxima/bugs/1062/#aea7


This is not only about the sign in the input . E.g.,

(%i27) cflength:3$ (%i28) cf((16*(119+48*sqrt(6)))/337); (%o28) [11, 4, 3, 4, 4, 5, 1, 27, 1, 6] period not visible ! And I claim the "5" is incorrect, should be "4" Though one can check that in all intermediate steps the sign of the sqrt(6) term is positive. Indeed : (%i29) float((16*(119+48*sqrt(6)))/337); (%o29) 11.23207157999252 (%i30) float(cfdisrep([11, 4, 3, 4, 4])); (%o30) 11.23206751054852 This term is below the true value, so next should be above : (%i31) float(cfdisrep([11, 4, 3, 4, 4, 4])); (%o31) 11.23207171314741 Correct _ is above (%i32) float(cfdisrep([11, 4, 3, 4, 4, 5])); (%o32) 11.232070910556 Wrong : is below.

JF Mertens