Here you can find the source of digamma(double x)
Parameter | Description |
---|---|
x | a parameter |
public static double digamma(double x)
//package com.java2s; //License from project: Apache License public class Main { public static final double c1 = -0.5; public static final double c2 = -1.0 / 12; public static final double c4 = 1.0 / 120; public static final double c6 = -1.0 / 252; /**/*w w w . j a va 2s .co m*/ * Compute the value of digamma function * * @param x * @return */ public static double digamma(double x) { double y, y2, sum = 0; for (y = x; y < 10; y++) { sum -= 1.0 / y; } y2 = 1.0 / (y * y); sum += Math.log(y) + c1 / y + y2 * (c2 + y2 * (c4 + y2 * c6)); return sum; } }