Smarter way to calculate middle-right terms of continued fraction partial sums

*To*: mathgroup at smc.vnet.net*Subject*: [mg70024] Smarter way to calculate middle-right terms of continued fraction partial sums*From*: "Diana" <diana.mecum at gmail.com>*Date*: Sat, 30 Sep 2006 05:13:05 -0400 (EDT)

Math folks I am trying to calculate the iterative terms of a continued fraction. It is a limit of partial sums of continued fractions defined as follows: x[n_]:= Sum as j goes from 1 to n of (z^q^j)/d[j], where d is a function of j. When n = 1, z = 1, and q = 2, x[1]:= 1/d[1] I then Solve[x[1] == 1/a1, a1] So, x[1] = {0, a1}, a two-term continued fraction. The second term looks like: x[2]:= 1/d[1] + 1/d[2] I then Solve[x[2] == 1/(a1 + (1/-a2 + (1/-a1))), a2] And get a partial sum which looks like x[2] = {0, a1, -a2, -a1}, a four-term continued fraction. x[3]:= 1/d[1] + 1/d[2] + 1/d[3] Solve[x[3] == 1/(a1 + (1/-a2 + (1/-a1 + (1/-a3 + (1/a1 + (1/a2 + (1/-a1))))))), a3] x[3] = {0, a1, -a2, -a1, -a3, a1, a2, -a1}, an eight-term continued fraction. So, each successive x[n] term is two times as long as the one before it, and I am always solving for the middle right term. After I have found the x[3] term, for example, I can plug the solved value of a3 into the Solve equation and solve for the x[4] term. The terms eventually look like the following: {0, a1, -a2, -a1, -a3, a1, a2, -a1, -a4, a1, -a2, -a1, a3, a1, a2, -a1, -a5, a1, -a2, -a1, -a3 a1, a2, -a1, a4, a1, -a2, -a1, a3, a1, a2, -a1, a6, ...} Note that the signs of a1 alternate between positive and positive. Likewise, all the variables alternate in sign. I have been coding the Solve equation as fractions of 1 over a1 + 1 over -a2 + 1 over, etc. By the fifth term, I have 63 fractions to code. I am sure there is a smarter way to do this, so I am posting this question to the news group. Can someone help? Diana

**RE: How to make a progress bar?**

**Re: How to make a progress bar?**

**Input, output troubles me ...**

**RE: Re: Re: distance function**