Exact Arithmetic using Continued Fractions

Click For Summary

Discussion Overview

The discussion centers on the development of a continued fraction-based exact arithmetic computational package, inspired by Bill Gosper's HACMEM algorithm and Peter Potts' Mobius transforms. Participants explore the efficiency and implementation of these algorithms, their application to complex numbers, and the challenges associated with termination in certain calculations.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant discusses enhancements to continued fraction algorithms, including pattern detection for exact solutions and automatic operation composition.
  • Concerns are raised about the termination of calculations involving transcendental functions and the potential inefficiency of continued fraction methods compared to other exact arithmetic methods.
  • Another participant mentions using a hybrid approach to continued fractions to address termination issues and expresses the need for better algorithms for transcendental functions.
  • There is a suggestion to explore connections with existing work on LCF and Mobius-based methods, indicating a broader context for the discussion.
  • A participant describes their system as having both a computational engine based on Gosper's algorithms and an analytic system utilizing LLTs, highlighting the integration of different methodologies.
  • Questions are raised about existing implementations of Gosper's algorithms and the specific problems the new system aims to solve.
  • The programming language used for the application is Python, noted for its features that support the development of the computational package.

Areas of Agreement / Disagreement

Participants express a range of views regarding the efficiency and applicability of continued fraction methods, with no consensus reached on the superiority of these methods compared to conventional approaches. The discussion remains unresolved regarding the effectiveness of the proposed optimizations and the challenges of implementing transcendental functions.

Contextual Notes

Participants note limitations related to the termination of certain calculations and the robustness of existing implementations of Gosper's algorithms. There is also mention of the comparative speed of continued fraction methods versus conventional IEEE arithmetic, which may depend on processor design.

Who May Find This Useful

Readers interested in computational mathematics, exact arithmetic, algorithm development, and the application of continued fractions in programming may find this discussion relevant.

KevB
Messages
11
Reaction score
0
I've recently started development on a continued fraction based exact arithmetic computational package. This is work based on Bill Gosper's HACMEM algorithm and Peter Potts' Mobius transforms with significant modifications. These algorithms have some remarkable properties and can be made much more efficient. Some enhancements I've developed include the ability to detect patterns which define exact solutions when they exist and a method to automatically compose operations (reducing operation counts significantly).

While these algorithms have been around since the early 70's (HACMEM was written in 1972), they don't seem to be commonly implemented commercially. Are these algorithms used in proprietary software (e.g. Mathematica )? I've seen some simple implementations, but most fail to address some of the issues Bill identified (e.g. non-termination when computing the square of a root).

I intend to release a version of this system to the public domain at some point, but was curious about similar systems that might exist. I'm also interested in applying these algorithms with complex numbers (which should be reasonably straightforward), and wondered if anyone had done this.
 
Technology news on Phys.org
KevB said:
I've recently started development on a continued fraction based exact arithmetic computational package. This is work based on Bill Gosper's HACMEM algorithm and Peter Potts' Mobius transforms with significant modifications. These algorithms have some remarkable properties and can be made much more efficient. Some enhancements I've developed include the ability to detect patterns which define exact solutions when they exist and a method to automatically compose operations (reducing operation counts significantly).

While these algorithms have been around since the early 70's (HACMEM was written in 1972), they don't seem to be commonly implemented commercially. Are these algorithms used in proprietary software (e.g. Mathematica )? I've seen some simple implementations, but most fail to address some of the issues Bill identified (e.g. non-termination when computing the square of a root).

I intend to release a version of this system to the public domain at some point, but was curious about similar systems that might exist. I'm also interested in applying these algorithms with complex numbers (which should be reasonably straightforward), and wondered if anyone had done this.

I'm not sure you can guarantee termination in cases such as computing f(g(x)) where x is integer and f(g(x)) is also integer, but g(x) is transcendental...

There seems to be a conclusion in the literature that CF-based methods are slower than other methods for exact arithmetic.

If you have significant optimizations, this could change everything.

Did you describe your optimizations in any papers? This would be interesting to look at.
 
If you use standard simple continued fractions you see the termination problems that Bill Gosper also described in his write up. I use a hybrid between simple and nearest-integer continued fractions to address this problem. I still need to derive better algorithms for calculations of some transcendental functions (sin and cos) for infinite continued fractions.

While I've done some optimization to combine operations I'm sure this algorithm isn't as fast as conventional IEEE arithmetic. It's not really a fair comparison since IEEE has limited precision. What other exact arithmetic algorithms exist? You also have to consider that most processors have floating point operations in hardware. If the processors were designed with integer matrix operations instead it would be a better comparison.

I'm just starting to write this up. Since I'm only playing with this in my free time it won't be quick.
 
Did you look at the work of Potts, Edalat, and others on LCF and Moebius-based methods? I wonder how your approach connects with those.
 
Thank you for your suggestions and comments.

I have looked at methods that use LLT and Mobius Transforms and incorporate many of those ideas into my system. I suppose you could say my system has two components, a computational engine (based on Gosper's algorithms), and a analytic system (based on LLTs). Gosper's algorithm is lazy, which allows one to accumulate the LLTs and combine them where possible through composition.

In some cases, such as computations of logarithms and exponentials, I use an interval method to determine the continued fraction coefficients, but most arithmetic operations don't require this additional overhead. I expect I'll need to use this interval approach for calculations of other transcendental functions (like sin and cos) as well.

The methods outlined by Gosper and the LLT and Mobius Transforms are obviously closely coupled. In my system I've tried to take advantage of each approaches strength. Gosper offers simple, lazy computation, while Mobius transforms provide flexible manipulation.
 
There are already some implementations of Gosper's algorithms. For example here:
http://contfrac.sourceforge.net/

What are the problems with Gosper's algorithms that you are primarily trying to solve?

Also, which programming language are you using? Just curious.
 
The application is programmed in Python as a new data type, with all the standard operators overridden. Python has a number of features, like portablility, unlimitted length integer computations, generator functions, and complete object oriented paradigm that makes it attractive. While Python isn't as fast as a compiled language cPython typically is.

I've looked at Creal as well as several other implementations of Gosper's scheme and have exchanged e-mails with some of the developers. Most are not very robust and don't support additional math functions (like log(CF), CFCF,sin(CF), cos(CF),...)
 

Similar threads

Replies
29
Views
6K
  • · Replies 1 ·
Replies
1
Views
505
Replies
2
Views
3K
Replies
6
Views
3K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 13 ·
Replies
13
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K