Title: High Precision Calculation of the Digamma Function
1High Precision Calculation of the Digamma Function
- Mohammad I Rafiq
- School of Computer Science, Carnegie Mellon
University - Research Advisor Dr. Victor Adamchik
2Goal of the Project
- The main goal of this research project is to
be able to compute the digamma and other related
special functions, to an arbitrary precision.
This has been implemented using NASA's ARPREC
package. The other important aspects of this
project are to deal with dynamically controlled
precision, self correcting error codes and fixed
precision calculations.
3Formulas for computation of the Digamma function
4Results
X -(110/213)-5 -110/213 110/213 110/213 5
Precision 1000 1000 1000 1000
Our time (sec) 3.69 3.31 2.15 3.32
Mathematica time (sec) 2.29 2.20 2.24 2.20
Accuracy 1000 1000 1000 1000
5Results(contd)
X -(110/213)-5 -110/213 110/213 110/213 5
Precision 2000 2000 2000 2000
Our time (sec) 32.36 33.23 32.01 31.93
Mathematica time (sec) 23.05 23.45 23.0 23.29
Accuracy 2000 2000 2000 2000
6- Problem
- Accuracy decreases as precision and x is
increased e.g. - 1) digamma(110/213 500) when calculated
at a precision of 500 gives an accuracy of 362. - 2) digamma(110/213 50) when calculated at a
precision of 1000 gives an accuracy of 781. - Solution
- To use an adaptive precision system rather
than a fixed precision system. An adaptive
precision system is a floating point system based
on significance arithmetic which dynamically
adjusts the number of digits used in
computations. This is also known as self
correcting error codes.
7Future Additions
- To add a two layer caching mechanism in order to
improve the calculation times. -
8- Splay Tree A stores the result corresponding to
each input x for a particular precision. If the
function is called multiple times for the same
input x, but with a different precision then only
the result of the higher precision is stored. - Splay Tree B stores the coefficients Ci in the
struct k_st, corresponding to each iteration i
for each precision. - Each time the function digamma(x,prec) is called,
we first search through A for x. If we find x and
the precision stored is equal or less than our
prec then we truncate the stored result and
output it. If we do not find x or our prec is
greater than the stored precision, then we search
through B for our prec. If we find our prec in
the tree, we use the stored coefficients to
calculate our result and also update Tree A with
the result. If we do not find our prec in B, we
calculate both the coefficients and the result
and update both Trees A and B.