On interacttion with C, Fortran, etc (wasRE: [Maxima] High precision)



Thanks for your answers.

In the question of bfloat versions of numerical functions, I have some
related questions.

1.  Is the mathematics for what may be the best way to implement such
     things now well understood, or are there interesting mathematical
     questions related to this?

2.  There are obviously many problems which could benefit from tools
     which permit all (or most) of the calculations being done in high
     (perhaps varying) precision. There are tools for high
     precision in fortran, python, maple, etc.  I don't have experience
     with these, so I don't know if they are useful for many things.

     Perhaps the best way to implement similar tools in maxima (as well
     as many other things) is to bring in the ability to call in
     subroutines from some of these other languages.

     I know that maxima can interface with lisp, but I don't know how
     easy it is to make in interact with C, C++, fortran, etc.

Are they any tools (or plans) for this?

TIA,

-Sheldon Newhouse





On Tue, 1 Aug 2006, Richard Fateman wrote:

> Numbers which are introduced as ordinary machine floats like 1.0 are forever
> machine floats unless you explicitly convert them.  If they are introduced
> as bigfloats, say as 1.0b0, then they will be bigfloats. The next time they
> are operated on, the result of the calculation will have precision fpprec.
>
> Oh, integers are left alone as integers, similarly for rationals.
> What you can sometimes do is,
>
> Myprogram(a,b,c):= (a:bfloat(a), b:bfloat(b), c:bfloat(c), .....);
>
> This is will convert a,b,c to bigfloats of the current fpprec. If they are
> already bigfloats, the cost is negligible.
>
> Oh, maybe your issue is this...  if you type this:  bfloat(0.1);
> Then the error in 0.1 as a single float will still be there, since that is
> the value you put in to the program. Converting it to bigfloat afterward
> means that the conversion from 1/10 to a binary number has been done to
> machine precision, and in binary. Thus inexactly. Compare to bfloat(1/10)
> or 0.1b0 which may have the accuracy you expect.  Not all functions have
> bfloat versions so they have to convert to something they know, like double
> precision, and then do the calculation.
> Feel free to contribute bfloat versions of numerical functions :)
>
> RJF
>
>
>
>> -----Original Message-----
>> From: maxima-admin at math.utexas.edu [mailto:maxima-admin at math.utexas.edu]
>> On Behalf Of sen1 at math.msu.edu
>> Sent: Tuesday, August 01, 2006 7:49 AM
>> To: maxima at math.utexas.edu
>> Subject: High precision
>>
>> Hello,
>>   I would like to run certain entire maxima sessions in high precision
>>   arithmetic.
>>
>> I have tried setting fpprec: 32.
>>
>> The numbers get listed as having that precision.  But, it seems that
>> floating point errors I expect from functions with standard double
>> precision are still there.  Does every single variable in an
>> expression have to be converted?
>>
>> Is it expected that, once one sets fpprec: 32, all further
>> computations, even with previously defined functions, will be at that
>> precision?
>>
>> Thanks for any info.
>>
>> -sen
>>
>> --
>>   ------------------------------------------------------------------------
>> ---
>>   | Sheldon E. Newhouse            |    e-mail: sen1 at math.msu.edu
>> |
>>   | Mathematics Department         |       				   |
>>   | Michigan State University      | telephone: 517-355-9684
>> |
>>   | E. Lansing, MI 48824-1027 USA  |       FAX: 517-432-1562
>> |
>>   ------------------------------------------------------------------------
>> ---
>>
>> _______________________________________________
>> Maxima mailing list
>> Maxima at math.utexas.edu
>> http://www.math.utexas.edu/mailman/listinfo/maxima
>

-- 
  ---------------------------------------------------------------------------
  | Sheldon E. Newhouse            |    e-mail: sen1 at math.msu.edu           |
  | Mathematics Department         |       				   |
  | Michigan State University      | telephone: 517-355-9684                |
  | E. Lansing, MI 48824-1027 USA  |       FAX: 517-432-1562                |
  ---------------------------------------------------------------------------