Maurice Lombardi wrote:
While using gmp for my own work gmp 4.1.2 for djgpp I have found small bugs in the interface gmp.pas which cause compiling errors when compiling for gmp 4 (it compiles fine with gmp 3) The diff file is attached: gmp.pas.minimal.diff
OK.
Notice that pi included in these formulas is computed by a double call to arctan ! This is not a closed loop because pi needs only x=1/5 and x=1/239 below the lowest threshold. (Moshier uses a constant for pi because he has a fixed number of digits).
OK. However, it might be worthwhile to cache pi (as long as precision suffices), like I do with LnHalf in mpf_ln. (Quite a similar situation, BTW: Also not a closed loop, though even a direct recursion there.) (Same for pi in mpf_sin and \sqrt 2 in mpf_arctan.)
I needed also the sin and cos functions. I have programmed the usual series development for sin, after reduction to the range [0,pi/2[, and cos(x)=sin(pi/2-x).
OK. I wonder if it would be better to store the value of `a' in the final loop in an integer variable instead. The range will certainly be enough (since it counts by 2 each turn). I haven't done timing tests, but I guess that dividing by an integer should at least not be slower than by an mpf_t that happens to represent an integer value, should it?
With this we have for gmp all the basic transcendental functions required for pascal (in the real type !)
Feel free to add the complex routines. :-)
Frank