Re: Program to calculate rational function with imbedded continued fraction
- To: mathgroup at smc.vnet.net
- Subject: [mg69958] Re: [mg69875] Program to calculate rational function with imbedded continued fraction
- From: "Diana Mecum" <diana.mecum at gmail.com>
- Date: Thu, 28 Sep 2006 06:15:39 -0400 (EDT)
Andrzej, Yes, I was using two types of notation in my e-mail to you, and I apologize for the sloppiness. For the purpose of Mathematica, I had set up a function g[i_] := T^2^i - T as you defined. You have solved my problem, and greatly assisted me with my master's thesis preparation. I now have the fodder I need to continue analyzing and drilling down on the proofs of the articles I am studying. Thank you very much for your time, I am very grateful! Diana M. On 9/27/06, Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote: > > What do you mean by: > > "do I plug (e(1) + 1)(T^2e(1)) in for k?." Are you using Mathematica > syntax or something else? All your messages seem to contain weird > mixture of Mathematica syntax, such as T^2^i and expressions which > are syntactically impermissible in Mathematica, such as [1] or [i], > etc. So what exactly did you "plug in" to get your error message? > When I run this program I do not get any error messages, but I use > correct Mathematica syntax. For example, let's define: > > g[i_] := T^2^i - T > > and take the following finite continued fraction: > > e[1] = {0, g[1], g[2], g[1], g[3], g[1], g[2], g[1], g[4], g[1], g > [2], g[1], g[ > 3], g[1], g[2], g[1], g[5]}; > > Let's convert it and to a rational function and Simplify (very > important!) > > k = Simplify[FromContinuedFraction[e[1]]] > > you will get a pretty long expression that I have decided to skip. > Now do: > > F[Numerator[k], Denominator[k]] > > and you will get a continued fraction in terms of T; no error > messages. This example works pretty fast but if your e[1] is > extremely long I can't of course guarantee Mathematica will manage it. > > > Andrzej Kozlowski > > On 27 Sep 2006, at 14:18, Diana Mecum wrote: > > > I apologize if my example was not clear. I was trying to keep it > > simple. > > > > I have an exponential function e(z), where z might equal 1, which > > is a continued fraction defined as follows: > > > > e(1) = [0, [1], [2], [1], [3], [1], [2], [1], [4], [1], [2], [1], > > [3], [1], [2], [1], [5], ...] > > > > [i] = T^2^i - T in characteristic 2. > > > > I am trying to learn how to evaluate > > > > (xe(1) + y)(ze(1) + w), where x, y, z, and w are polynomials in T, > > and xw - yz != 0. > > > > So, for any given example, such as > > > > (e(1) + 1)(T^2e(1), I am trying to determine what the continued > > fraction for it would be. > > > > I see your program. Thanks for forwarding it. > > > > To implement it, do I plug (e(1) + 1)(T^2e(1) in for k? > > > > When I run the routine, I get an error saying that the tags in In > > [50] and In[51] are protected. > > > > Thanks for your time, > > > > Diana M. > > > > > > > > > > On 9/26/06, Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote: *This > > On 26 Sep 2006, at 18:21, Diana wrote: > > > > > Hello all, > > > > > > Would someone be able to help me write a program to calculate the > > > rational function of (2x + 3)/(2x + 4), for example? > > > > I have once already posted such a program and so did Daniel > > Lichtblau. (Search the archive for the subject "How to do Continued > > fraction of polynomials" and compare our posts. (I can't remember any > > more what the difference between them was). > > > > Here is my version: > > > > F[f_, g_] := > > If[PolynomialReduce[f, g][[1, 1]] =!= 0, PolynomialReduce[f, > > g][[ > > 1, 1]] + F[PolynomialReduce[f, > > g][[2]], g], Module[{u = g, v = f, p, ls}, ls = Flatten[Last[ > > Reap[While[u =!= 0, p = PolynomialReduce[u, v]; u = v; v = > > p[[2]]; Sow[ > > p[[1]]]]]]]; 1/Fold[Function[{x, y}, y + 1/x], Infinity, > > Reverse[ls]]]] > > > > In the case of your example above you need to evaluate: > > > > In[50]:= > > k=(2x+3)/(2x+4); > > > > In[51]:= > > F[Numerator[k],Denominator[k]] > > > > Out[51]= > > 1 + 1/(-2*x - 4) > > > > > > > > > > > > > > Also, (tx + 2t)(3t^2x + t), for example. > > > > > > What exactly do you mean? This does not make sense to me; is that a > > quotient? If so why did't you cancel the t's? I think the case of > > rational functions in several variables will be much harder, and I > > would have to think more about it, for which I do not have the time > > at this moment, and in any case it might not be what you are asking > > for. > > > > > > > > > > x is actually an infinite continued fraction, and I am trying to > > > figure > > > out how to divide one infinite continued fraction by another. > > > > > > (t [0, 1, 2, 1, 3, 1, 2, 1, 4, ...] + 2t)/(3t^2 [0, 1, 2, 1, 3, > > 1, 2, > > > 1, 4, ...] +t) > > > > > > > > > I think this can be done combining the built in function > > FromContinuedFraction with the function F defined above. > > > > Andrzej Kozlowski > > > > Tokyo, Japan > > > >