Actually, these values are sufficient to find the continued fraction expansions of both %: 2 and %: 61. For square roots, the continued fraction expansion is of the form
a0 a1 a2 ... an a1 a2 .... an ..... where an is the first value such that an=2*a0. If you know the first 2 terms for %: 2 are 1 2, you know the entire expansion is 1 2 2 2 2 .... . If you know the first few terms for %: 61 are 7 1 4 3 1 2 2 1 3 4 1 14 you know it now recurs. Best wishes, John p j wrote: > These are 2 functions from the phrase page on the wiki > for dealing with continued fractions. > > cf=:]`(<. , $:@%@(1&|))@.(~: <.) > ecf=: (+%)/ > > First, if you don't call cf with an x: before its > argument, J601beta will shutdown on error (I dont know > what the error is) > > The main problem, > cf x: %: 2 > 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 45 2 1 2 11 1 3 6 > cf x:!.0 %: 2 > 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 1 4 2 5 9 > 3 3 1 11 57 2 > > The real answer for %: 2 is 1 2, and the most rational > expectation of how the above functions would behave is > to give us 1 2 2 2 2 2 2 2 for as long as its > precision allows. > Deep frustration and hard to track bugs occur because > of the "random" divergence from the accurate solution > that occurs even with x!.0. You need mathworld pages, > or modelling the problem in another language to find > these errors! > > One application for deep precision is to solve Pell > Equations x^2-Dy^2 = 1 > > cf (x:!.0) %: 61 > 7 1 4 3 1 2 2 1 3 4 1 14 1 4 3 1 2 2 1 4 3 2 1 3 2 2 2 > 1 1 2 1 3 3 3 1 1 2 2 > gives only 2 extra digits of precision over: > cf (x:) %: 61 > 7 1 4 3 1 2 2 1 3 4 1 14 1 4 3 1 1 3 1 115 20 10 1 3 3 > realcf 61 > 7 1 4 3 1 2 2 1 3 4 1 14 > > Even though the cf string produced by cf (x:!.0) %: 61 > is long enough to solve the Pell Equation for D= 61, > the fact that only its first 18 digits are accurate > means that expanding it through > ecf\ cf x:!.0 %:61 > fails to find the Pell solution. > > I will recap the levels of frustration involved: > * Consuming a function good enough to be published on > J's site requires a thorough understanding of its > potential failings for high input values. Makes > consuming functions you don't understand dangerous. > * The strategy of fixing code by randomly sprinkling > x:!.0 everywhere doesn't work because even then, > you're only slightly postponing the point where > solutions go into random expansion. > * There is no global switch to turn off random padding > of numbers so programs give incorrect results instead > of an error. You need to have a source for the right > solutions, to tell that high input values give > incorrect results. > > I would appreciate a global switch that would make the > following results for the cf verb. > cf x: %: 2 > 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 > cf x:!.0 %: 2 > 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
