Subject: Implementation of the Incomplete Beta function
From: Raymond Toy
Date: Sun, 25 Jan 2009 11:09:22 -0500
Dieter Kaiser wrote:
>
> The implementation is not as complete as for other functions, but it might be
> good to have an example for the package bigfloat. I will add further
> functionality to beta_incomplete.
>
Yes, I think an example of how to use the bigfloat package is a good
idea. Thanks for doing this.
An alternative way would be to put an (in-package "BIGFLOAT") before the
implementation so you don't have to type the package qualifier
everywhere. Just remember to put a (in-package "MAXIMA") afterwords!
> A Maxima rational as the first argument:
>
> (%i4) beta_incomplete(1/2,2.8,0.73);
> Maxima encountered a Lisp error:
>
> Error in MACSYMA-TOP-LEVEL [or a callee]: No matching method for the
> generic-function #<compiled-closure BIGFLOAT::TWO-ARG-*>,
> when called with arguments (NIL 1.6764907877644366).
>
This is tricky. It fails because the beta_incomplete calls ($gamma a),
a = 1/2. It return sqrt(%pi) and wants bigfloat:to to convert it. I
think that's outside the scope of bigfloat. The code needs to convert
that to either a float or a bfloat.
>
> The symbol %i as argument:
>
> (%i10) beta_incomplete(0.5,%i,1.5);
> BIGFLOAT: Unable to convert %i to a CL or BIGFLOAT number
> -- an error. To debug this try debugmode(true);
>
This is a bug in bigfloat:to. It needs to recognize $%i. I'll fix
this. But I don't think bigfloat:to can handle %pi, %e or %gamma. The
caller needs to convert those to a float or bfloat before calling
bigfloat routines.
> Remark: It is necessary to support rationals also in expressions like
> 1/2+0.5*%i.
>
Yes, this should work. I'll fix it.
> I would be posssible to do some workarounds in the code of beta_incomplete. But
> I think it is better to have the package bigfloat as complete as possible.
>
I agree. The intent is that if you have some code that works for
double-floats, then you should be able to use that code unchanged
(almost) in the bigfloat package. If the code uses declarations or
double-float constants, you'll have to change that, of course.
Ray