org.apache.commons.math3.special.Gamma.trigamma()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(161)

本文整理了Java中org.apache.commons.math3.special.Gamma.trigamma()方法的一些代码示例,展示了Gamma.trigamma()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Gamma.trigamma()方法的具体详情如下:
包路径:org.apache.commons.math3.special.Gamma
类名称:Gamma
方法名:trigamma

Gamma.trigamma介绍

[英]Computes the trigamma function of x. This function is derived by taking the derivative of the implementation of digamma.
[中]

代码示例

代码示例来源:origin: org.apache.commons/commons-math3

/**
 * Computes the trigamma function of x.
 * This function is derived by taking the derivative of the implementation
 * of digamma.
 *
 * @param x Argument.
 * @return trigamma(x) to within 10-8 relative or absolute error whichever is smaller
 * @see <a href="http://en.wikipedia.org/wiki/Trigamma_function">Trigamma</a>
 * @see Gamma#digamma(double)
 * @since 2.0
 */
public static double trigamma(double x) {
  if (Double.isNaN(x) || Double.isInfinite(x)) {
    return x;
  }
  if (x > 0 && x <= S_LIMIT) {
    return 1 / (x * x);
  }
  if (x >= C_LIMIT) {
    double inv = 1 / (x * x);
    //  1    1      1       1       1
    //  - + ---- + ---- - ----- + -----
    //  x      2      3       5       7
    //      2 x    6 x    30 x    42 x
    return 1 / x + inv / 2 + inv / x * (1.0 / 6 - inv * (1.0 / 30 + inv / 42));
  }
  return trigamma(x + 1) + 1 / (x * x);
}

代码示例来源:origin: geogebra/geogebra

/**
 * Computes the trigamma function of x.
 * This function is derived by taking the derivative of the implementation
 * of digamma.
 *
 * @param x Argument.
 * @return trigamma(x) to within 10-8 relative or absolute error whichever is smaller
 * @see <a href="http://en.wikipedia.org/wiki/Trigamma_function">Trigamma</a>
 * @see Gamma#digamma(double)
 * @since 2.0
 */
public static double trigamma(double x) {
  if (Double.isNaN(x) || Double.isInfinite(x)) {
    return x;
  }
  if (x > 0 && x <= S_LIMIT) {
    return 1 / (x * x);
  }
  if (x >= C_LIMIT) {
    double inv = 1 / (x * x);
    //  1    1      1       1       1
    //  - + ---- + ---- - ----- + -----
    //  x      2      3       5       7
    //      2 x    6 x    30 x    42 x
    return 1 / x + inv / 2 + inv / x * (1.0 / 6 - inv * (1.0 / 30 + inv / 42));
  }
  return trigamma(x + 1) + 1 / (x * x);
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Computes the trigamma function of x.
 * This function is derived by taking the derivative of the implementation
 * of digamma.
 *
 * @param x Argument.
 * @return trigamma(x) to within 10-8 relative or absolute error whichever is smaller
 * @see <a href="http://en.wikipedia.org/wiki/Trigamma_function">Trigamma</a>
 * @see Gamma#digamma(double)
 * @since 2.0
 */
public static double trigamma(double x) {
  if (Double.isNaN(x) || Double.isInfinite(x)) {
    return x;
  }
  if (x > 0 && x <= S_LIMIT) {
    return 1 / (x * x);
  }
  if (x >= C_LIMIT) {
    double inv = 1 / (x * x);
    //  1    1      1       1       1
    //  - + ---- + ---- - ----- + -----
    //  x      2      3       5       7
    //      2 x    6 x    30 x    42 x
    return 1 / x + inv / 2 + inv / x * (1.0 / 6 - inv * (1.0 / 30 + inv / 42));
  }
  return trigamma(x + 1) + 1 / (x * x);
}

代码示例来源:origin: net.rapture/Reflex

public ReflexValue trigamma(List<ReflexValue> params) {
  if (params.size() != 1) {
    throw new ReflexException(-1, "trigamma needs one number parameter");
  }
  if (!params.get(0).isNumber()) {
    throw new ReflexException(-1, "trigamma needs one number parameter");
  }
  double value = params.get(0).asDouble();
  return new ReflexValue(Gamma.trigamma(value));
}

代码示例来源:origin: geogebra/geogebra

/**
 * @param order
 *            polynomial order
 * @param x
 *            real number
 * @return polyGamma_order(x)
 */
final public static double polyGamma(NumberValue order, double x) {
  int o = (int) order.getDouble();
  switch (o) {
  case 0:
    return Gamma.digamma(x);
  case 1:
    return Gamma.trigamma(x);
  // case 2:
  // return PolyGamma.tetragamma(x);
  // case 3:
  // return PolyGamma.pentagamma(x);
  // default:
  // return PolyGamma.psigamma(x, o);
  default:
    return Double.NaN;
  }
}

相关文章