Sarnold 28 May 2006 -- *Bigfloat for Tcl* is a pure-Tcl mathematic package part of tcllib since 1.8. On this wiki, see math::bigfloat.

It relies on the math::bignum package, for big integers conveniences, but a version using Tcl 8.5 and its builtin bignum functionality has been built. It will load the 8.5-specific version when possible, otherwise you will just get the 8.4 compatible version.

You can take a look at [L1 ] for some motivations for interval computations and extreme floating-point precision.

AM (2 february 2005)

I realised the other day that this package can not only be used to compute with high accuracy, you can use it to inspect the effect of *any* number of decimals. This is not uncommon in textbooks on numerical analysis.

Sarnold I am sorry, but I don't see what you mean. Could you give an example of inspecting this effect ?

AM Suppose you have a vector (1.100,1.001) (so three decimals), to compute the length you *could* do:

expr {hypot(1.100,1.001)}

but that would mean that you use all decimals that a floating-point number in Tcl has (some 12). You can not easily do the computation with *only* the significant decimals. (Well you could truncate the number, but that is not quite the same). If instead you rely on the computations to be done using no more than three decimals (including the intermediate results), the effect of limited decimals becomes clearer - you simply vary the number of decimals.

An example of this kind of analysis can be found in:

J.C. Nash Compact Numerical Methods for Computers, (Adam Hilger, 1990)

Sarnold 04/01/2005

BigFloat for Tcl *v1.1a1* is released at [no longer here]. The test suite and the doctools man page are written. Just one problem : the test suite runs in 2 min. It would be too long for including it in tcllib, wouldn't it be ?

AM (4 january 2005) Testsuites are meant to check the code, they are used every once in a while. I do not think 2 minutes is too long, though of course that depends on the number of tests too :)

LV Shoot - if it ran for an hour, that would be fine with me - though I think I'd like it to let me know that was coming. What I would want, however, was assurance that in the end, the package is working really well...

Sarnold It takes approx. 120 seconds, but it does 592 unit tests. The way it works : it compares the result with expr' same function, so the comparison is limited to 12 decimals.

AK: The first testsuite for grammar_fa ran several ten-thousands of tests and took 20 minutes or longer. The largest stuff has been cut, but it is still in the several minutes range. So, your two minutes and 600 tests are not really that much. I do not consider this an impediment to the integration of that code.

Sarnold Thank you for your remarks. It does not bother anymore to have such a test suite. I consider the discussion closed.

**Past discussion :**

LV Is the intent for this to be a tcl script only package; something that might be contributed to tcllib?

Sarnold Sure, I first asked if MPA could be contributed to tcllib, and after I realized there was an interest for it, I decided that MPA would become BigFloat for Tcl.

I am currently rewriting all MPA into one namespace called *::math::bigfloat* and the name of the package should be *bigfloat*. There is a lot of work, but I think I will have done it for February 2005. Wait and see. *Done, but the package has to be brought to tcllib*

TV *(feb 3 '04)*: Maxima also has infinte accuracy numbers and computations, of course bounded by the computers' memory and it's efficiency and your time to wait for the answer. And tcl is in fact used in the main interface of the recent versions of the currently open source mathematics package. It can be most easily integrated with tcl probably by using the process as a function call, which works fine under linux, see Bwise blocks using exec maxima for examples. Of course then one can also *manipulate* formulas and variables with numerals, but the package isn't extremely compact, and probably not necessarily fast for big numbers. Symbolics win of approximations in the end for problems which are solved by them, of course..

AM A simple application of the bigfloat package appears in Nested Radical Constant

See also math::bigfloat, math::bignum, Tcllib