You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by td...@apache.org on 2010/08/14 23:19:02 UTC

svn commit: r985582 - in /mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/math: Arithmetic.java Bessel.java

Author: tdunning
Date: Sat Aug 14 21:19:02 2010
New Revision: 985582

URL: http://svn.apache.org/viewvc?rev=985582&view=rev
Log:
Style improvements.

Modified:
    mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/math/Arithmetic.java
    mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/math/Bessel.java

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/math/Arithmetic.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/math/Arithmetic.java?rev=985582&r1=985581&r2=985582&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/math/Arithmetic.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/math/Arithmetic.java Sat Aug 14 21:19:02 2010
@@ -31,217 +31,217 @@ package org.apache.mahout.math.jet.math;
  */
 public class Arithmetic extends Constants {
   // for method stirlingCorrection(...)
-  private static final double[] stirlingCorrection = {
-      0.0,
-      8.106146679532726e-02, 4.134069595540929e-02,
-      2.767792568499834e-02, 2.079067210376509e-02,
-      1.664469118982119e-02, 1.387612882307075e-02,
-      1.189670994589177e-02, 1.041126526197209e-02,
-      9.255462182712733e-03, 8.330563433362871e-03,
-      7.573675487951841e-03, 6.942840107209530e-03,
-      6.408994188004207e-03, 5.951370112758848e-03,
-      5.554733551962801e-03, 5.207655919609640e-03,
-      4.901395948434738e-03, 4.629153749334029e-03,
-      4.385560249232324e-03, 4.166319691996922e-03,
-      3.967954218640860e-03, 3.787618068444430e-03,
-      3.622960224683090e-03, 3.472021382978770e-03,
-      3.333155636728090e-03, 3.204970228055040e-03,
-      3.086278682608780e-03, 2.976063983550410e-03,
-      2.873449362352470e-03, 2.777674929752690e-03,
+  private static final double[] STIRLING_CORRECTION_TABLE = {
+    0.0,
+    8.106146679532726e-02, 4.134069595540929e-02,
+    2.767792568499834e-02, 2.079067210376509e-02,
+    1.664469118982119e-02, 1.387612882307075e-02,
+    1.189670994589177e-02, 1.041126526197209e-02,
+    9.255462182712733e-03, 8.330563433362871e-03,
+    7.573675487951841e-03, 6.942840107209530e-03,
+    6.408994188004207e-03, 5.951370112758848e-03,
+    5.554733551962801e-03, 5.207655919609640e-03,
+    4.901395948434738e-03, 4.629153749334029e-03,
+    4.385560249232324e-03, 4.166319691996922e-03,
+    3.967954218640860e-03, 3.787618068444430e-03,
+    3.622960224683090e-03, 3.472021382978770e-03,
+    3.333155636728090e-03, 3.204970228055040e-03,
+    3.086278682608780e-03, 2.976063983550410e-03,
+    2.873449362352470e-03, 2.777674929752690e-03,
   };
 
   // for method logFactorial(...)
   // log(k!) for k = 0, ..., 29
-  private static final double[] logFactorials = {
-      0.00000000000000000, 0.00000000000000000, 0.69314718055994531,
-      1.79175946922805500, 3.17805383034794562, 4.78749174278204599,
-      6.57925121201010100, 8.52516136106541430, 10.60460290274525023,
-      12.80182748008146961, 15.10441257307551530, 17.50230784587388584,
-      19.98721449566188615, 22.55216385312342289, 25.19122118273868150,
-      27.89927138384089157, 30.67186010608067280, 33.50507345013688888,
-      36.39544520803305358, 39.33988418719949404, 42.33561646075348503,
-      45.38013889847690803, 48.47118135183522388, 51.60667556776437357,
-      54.78472939811231919, 58.00360522298051994, 61.26170176100200198,
-      64.55753862700633106, 67.88974313718153498, 71.25703896716800901
+  private static final double[] LOG_FACTORIAL_TABLE = {
+    0.00000000000000000, 0.00000000000000000, 0.69314718055994531,
+    1.79175946922805500, 3.17805383034794562, 4.78749174278204599,
+    6.57925121201010100, 8.52516136106541430, 10.60460290274525023,
+    12.80182748008146961, 15.10441257307551530, 17.50230784587388584,
+    19.98721449566188615, 22.55216385312342289, 25.19122118273868150,
+    27.89927138384089157, 30.67186010608067280, 33.50507345013688888,
+    36.39544520803305358, 39.33988418719949404, 42.33561646075348503,
+    45.38013889847690803, 48.47118135183522388, 51.60667556776437357,
+    54.78472939811231919, 58.00360522298051994, 61.26170176100200198,
+    64.55753862700633106, 67.88974313718153498, 71.25703896716800901
   };
 
   // k! for k = 0, ..., 20
-  private static final long[] longFactorials = {
-      1L,
-      1L,
-      2L,
-      6L,
-      24L,
-      120L,
-      720L,
-      5040L,
-      40320L,
-      362880L,
-      3628800L,
-      39916800L,
-      479001600L,
-      6227020800L,
-      87178291200L,
-      1307674368000L,
-      20922789888000L,
-      355687428096000L,
-      6402373705728000L,
-      121645100408832000L,
-      2432902008176640000L
+  private static final long[] FACTORIAL_TABLE = {
+    1L,
+    1L,
+    2L,
+    6L,
+    24L,
+    120L,
+    720L,
+    5040L,
+    40320L,
+    362880L,
+    3628800L,
+    39916800L,
+    479001600L,
+    6227020800L,
+    87178291200L,
+    1307674368000L,
+    20922789888000L,
+    355687428096000L,
+    6402373705728000L,
+    121645100408832000L,
+    2432902008176640000L
   };
 
   // k! for k = 21, ..., 170
-  private static final double[] doubleFactorials = {
-      5.109094217170944E19,
-      1.1240007277776077E21,
-      2.585201673888498E22,
-      6.204484017332394E23,
-      1.5511210043330984E25,
-      4.032914611266057E26,
-      1.0888869450418352E28,
-      3.048883446117138E29,
-      8.841761993739701E30,
-      2.652528598121911E32,
-      8.222838654177924E33,
-      2.6313083693369355E35,
-      8.68331761881189E36,
-      2.952327990396041E38,
-      1.0333147966386144E40,
-      3.719933267899013E41,
-      1.3763753091226346E43,
-      5.23022617466601E44,
-      2.0397882081197447E46,
-      8.15915283247898E47,
-      3.34525266131638E49,
-      1.4050061177528801E51,
-      6.041526306337384E52,
-      2.6582715747884495E54,
-      1.196222208654802E56,
-      5.502622159812089E57,
-      2.5862324151116827E59,
-      1.2413915592536068E61,
-      6.082818640342679E62,
-      3.0414093201713376E64,
-      1.5511187532873816E66,
-      8.06581751709439E67,
-      4.274883284060024E69,
-      2.308436973392413E71,
-      1.2696403353658264E73,
-      7.109985878048632E74,
-      4.052691950487723E76,
-      2.350561331282879E78,
-      1.386831185456898E80,
-      8.32098711274139E81,
-      5.075802138772246E83,
-      3.146997326038794E85,
-      1.9826083154044396E87,
-      1.2688693218588414E89,
-      8.247650592082472E90,
-      5.443449390774432E92,
-      3.6471110918188705E94,
-      2.48003554243683E96,
-      1.7112245242814127E98,
-      1.1978571669969892E100,
-      8.504785885678624E101,
-      6.123445837688612E103,
-      4.470115461512686E105,
-      3.307885441519387E107,
-      2.4809140811395404E109,
-      1.8854947016660506E111,
-      1.451830920282859E113,
-      1.1324281178206295E115,
-      8.94618213078298E116,
-      7.15694570462638E118,
-      5.797126020747369E120,
-      4.7536433370128435E122,
-      3.94552396972066E124,
-      3.314240134565354E126,
-      2.8171041143805494E128,
-      2.4227095383672744E130,
-      2.107757298379527E132,
-      1.854826422573984E134,
-      1.6507955160908465E136,
-      1.4857159644817605E138,
-      1.3520015276784033E140,
-      1.2438414054641305E142,
-      1.156772507081641E144,
-      1.0873661566567426E146,
-      1.0329978488239061E148,
-      9.916779348709491E149,
-      9.619275968248216E151,
-      9.426890448883248E153,
-      9.332621544394415E155,
-      9.332621544394418E157,
-      9.42594775983836E159,
-      9.614466715035125E161,
-      9.902900716486178E163,
-      1.0299016745145631E166,
-      1.0813967582402912E168,
-      1.1462805637347086E170,
-      1.2265202031961373E172,
-      1.324641819451829E174,
-      1.4438595832024942E176,
-      1.5882455415227423E178,
-      1.7629525510902457E180,
-      1.974506857221075E182,
-      2.2311927486598138E184,
-      2.543559733472186E186,
-      2.925093693493014E188,
-      3.393108684451899E190,
-      3.96993716080872E192,
-      4.6845258497542896E194,
-      5.574585761207606E196,
-      6.689502913449135E198,
-      8.094298525273444E200,
-      9.875044200833601E202,
-      1.2146304367025332E205,
-      1.506141741511141E207,
-      1.882677176888926E209,
-      2.3721732428800483E211,
-      3.0126600184576624E213,
-      3.856204823625808E215,
-      4.974504222477287E217,
-      6.466855489220473E219,
-      8.471580690878813E221,
-      1.1182486511960037E224,
-      1.4872707060906847E226,
-      1.99294274616152E228,
-      2.690472707318049E230,
-      3.6590428819525483E232,
-      5.0128887482749884E234,
-      6.917786472619482E236,
-      9.615723196941089E238,
-      1.3462012475717523E241,
-      1.8981437590761713E243,
-      2.6953641378881633E245,
-      3.8543707171800694E247,
-      5.550293832739308E249,
-      8.047926057471989E251,
-      1.1749972043909107E254,
-      1.72724589045464E256,
-      2.5563239178728637E258,
-      3.8089226376305687E260,
-      5.7133839564458575E262,
-      8.627209774233244E264,
-      1.3113358856834527E267,
-      2.0063439050956838E269,
-      3.0897696138473515E271,
-      4.789142901463393E273,
-      7.471062926282892E275,
-      1.1729568794264134E278,
-      1.8532718694937346E280,
-      2.946702272495036E282,
-      4.714723635992061E284,
-      7.590705053947223E286,
-      1.2296942187394494E289,
-      2.0044015765453032E291,
-      3.287218585534299E293,
-      5.423910666131583E295,
-      9.003691705778434E297,
-      1.5036165148649983E300,
-      2.5260757449731988E302,
-      4.2690680090047056E304,
-      7.257415615308004E306
+  private static final double[] LARGE_FACTORIAL_TABLE = {
+    5.109094217170944E19,
+    1.1240007277776077E21,
+    2.585201673888498E22,
+    6.204484017332394E23,
+    1.5511210043330984E25,
+    4.032914611266057E26,
+    1.0888869450418352E28,
+    3.048883446117138E29,
+    8.841761993739701E30,
+    2.652528598121911E32,
+    8.222838654177924E33,
+    2.6313083693369355E35,
+    8.68331761881189E36,
+    2.952327990396041E38,
+    1.0333147966386144E40,
+    3.719933267899013E41,
+    1.3763753091226346E43,
+    5.23022617466601E44,
+    2.0397882081197447E46,
+    8.15915283247898E47,
+    3.34525266131638E49,
+    1.4050061177528801E51,
+    6.041526306337384E52,
+    2.6582715747884495E54,
+    1.196222208654802E56,
+    5.502622159812089E57,
+    2.5862324151116827E59,
+    1.2413915592536068E61,
+    6.082818640342679E62,
+    3.0414093201713376E64,
+    1.5511187532873816E66,
+    8.06581751709439E67,
+    4.274883284060024E69,
+    2.308436973392413E71,
+    1.2696403353658264E73,
+    7.109985878048632E74,
+    4.052691950487723E76,
+    2.350561331282879E78,
+    1.386831185456898E80,
+    8.32098711274139E81,
+    5.075802138772246E83,
+    3.146997326038794E85,
+    1.9826083154044396E87,
+    1.2688693218588414E89,
+    8.247650592082472E90,
+    5.443449390774432E92,
+    3.6471110918188705E94,
+    2.48003554243683E96,
+    1.7112245242814127E98,
+    1.1978571669969892E100,
+    8.504785885678624E101,
+    6.123445837688612E103,
+    4.470115461512686E105,
+    3.307885441519387E107,
+    2.4809140811395404E109,
+    1.8854947016660506E111,
+    1.451830920282859E113,
+    1.1324281178206295E115,
+    8.94618213078298E116,
+    7.15694570462638E118,
+    5.797126020747369E120,
+    4.7536433370128435E122,
+    3.94552396972066E124,
+    3.314240134565354E126,
+    2.8171041143805494E128,
+    2.4227095383672744E130,
+    2.107757298379527E132,
+    1.854826422573984E134,
+    1.6507955160908465E136,
+    1.4857159644817605E138,
+    1.3520015276784033E140,
+    1.2438414054641305E142,
+    1.156772507081641E144,
+    1.0873661566567426E146,
+    1.0329978488239061E148,
+    9.916779348709491E149,
+    9.619275968248216E151,
+    9.426890448883248E153,
+    9.332621544394415E155,
+    9.332621544394418E157,
+    9.42594775983836E159,
+    9.614466715035125E161,
+    9.902900716486178E163,
+    1.0299016745145631E166,
+    1.0813967582402912E168,
+    1.1462805637347086E170,
+    1.2265202031961373E172,
+    1.324641819451829E174,
+    1.4438595832024942E176,
+    1.5882455415227423E178,
+    1.7629525510902457E180,
+    1.974506857221075E182,
+    2.2311927486598138E184,
+    2.543559733472186E186,
+    2.925093693493014E188,
+    3.393108684451899E190,
+    3.96993716080872E192,
+    4.6845258497542896E194,
+    5.574585761207606E196,
+    6.689502913449135E198,
+    8.094298525273444E200,
+    9.875044200833601E202,
+    1.2146304367025332E205,
+    1.506141741511141E207,
+    1.882677176888926E209,
+    2.3721732428800483E211,
+    3.0126600184576624E213,
+    3.856204823625808E215,
+    4.974504222477287E217,
+    6.466855489220473E219,
+    8.471580690878813E221,
+    1.1182486511960037E224,
+    1.4872707060906847E226,
+    1.99294274616152E228,
+    2.690472707318049E230,
+    3.6590428819525483E232,
+    5.0128887482749884E234,
+    6.917786472619482E236,
+    9.615723196941089E238,
+    1.3462012475717523E241,
+    1.8981437590761713E243,
+    2.6953641378881633E245,
+    3.8543707171800694E247,
+    5.550293832739308E249,
+    8.047926057471989E251,
+    1.1749972043909107E254,
+    1.72724589045464E256,
+    2.5563239178728637E258,
+    3.8089226376305687E260,
+    5.7133839564458575E262,
+    8.627209774233244E264,
+    1.3113358856834527E267,
+    2.0063439050956838E269,
+    3.0897696138473515E271,
+    4.789142901463393E273,
+    7.471062926282892E275,
+    1.1729568794264134E278,
+    1.8532718694937346E280,
+    2.946702272495036E282,
+    4.714723635992061E284,
+    7.590705053947223E286,
+    1.2296942187394494E289,
+    2.0044015765453032E291,
+    3.287218585534299E293,
+    5.423910666131583E295,
+    9.003691705778434E297,
+    1.5036165148649983E300,
+    2.5260757449731988E302,
+    4.2690680090047056E304,
+    7.257415615308004E306
   };
 
   /** Makes this class non instantiable, but still let's others inherit from it. */
@@ -298,15 +298,15 @@ public class Arithmetic extends Constant
     // try quick version and see whether we get numeric overflows.
     // factorial(..) is O(1); requires no loop; only a table lookup.
     if (n > k) {
-      int max = longFactorials.length + doubleFactorials.length;
+      int max = FACTORIAL_TABLE.length + LARGE_FACTORIAL_TABLE.length;
       if (n < max) { // if (n! < inf && k! < inf)
-        double n_fac = factorial((int) n);
-        double k_fac = factorial((int) k);
-        double n_minus_k_fac = factorial((int) (n - k));
-        double nk = n_minus_k_fac * k_fac;
+        double nFactorial = factorial((int) n);
+        double kFactorial = factorial((int) k);
+        double nMinusKFactorial = factorial((int) (n - k));
+        double nk = nMinusKFactorial * kFactorial;
         if (nk != Double.POSITIVE_INFINITY) { // no numeric overflow?
           // now this is completely safe and accurate
-          return n_fac / nk;
+          return nFactorial / nk;
         }
       }
       if (k > n / 2) {
@@ -351,15 +351,15 @@ public class Arithmetic extends Constant
    *
    * @param x    argument to the polynomial.
    * @param coef the coefficients of the polynomial.
-   * @param N    the number of coefficients.
+   * @param n    the number of coefficients.
    */
-  public static double chbevl(double x, double[] coef, int N) throws ArithmeticException {
+  public static double chbevl(double x, double[] coef, int n) {
 
     int p = 0;
 
     double b0 = coef[p++];
     double b1 = 0.0;
-    int i = N - 1;
+    int i = n - 1;
 
     double b2;
     do {
@@ -368,7 +368,7 @@ public class Arithmetic extends Constant
       b0 = x * b1 - b2 + coef[p++];
     } while (--i > 0);
 
-    return (0.5 * (b0 - b2));
+    return 0.5 * (b0 - b2);
   }
 
   /**
@@ -381,14 +381,14 @@ public class Arithmetic extends Constant
       throw new IllegalArgumentException();
     }
 
-    int length1 = longFactorials.length;
+    int length1 = FACTORIAL_TABLE.length;
     if (k < length1) {
-      return longFactorials[k];
+      return FACTORIAL_TABLE[k];
     }
 
-    int length2 = doubleFactorials.length;
+    int length2 = LARGE_FACTORIAL_TABLE.length;
     if (k < length1 + length2) {
-      return doubleFactorials[k - length1];
+      return LARGE_FACTORIAL_TABLE[k - length1];
     } else {
       return Double.POSITIVE_INFINITY;
     }
@@ -431,14 +431,14 @@ public class Arithmetic extends Constant
 
       double r = 1.0 / (double) k;
       double rr = r * r;
-      double C7 = -5.95238095238095238e-04;
-      double C5 = 7.93650793650793651e-04;
-      double C3 = -2.77777777777777778e-03;
-      double C1 = 8.33333333333333333e-02;
-      double C0 = 9.18938533204672742e-01;
-      return (k + 0.5) * Math.log(k) - k + C0 + r * (C1 + rr * (C3 + rr * (C5 + rr * C7)));
+      double c7 = -5.95238095238095238e-04;
+      double c5 = 7.93650793650793651e-04;
+      double c3 = -2.77777777777777778e-03;
+      double c1 = 8.33333333333333333e-02;
+      double c0 = 9.18938533204672742e-01;
+      return (k + 0.5) * Math.log(k) - k + c0 + r * (c1 + rr * (c3 + rr * (c5 + rr * c7)));
     } else {
-      return logFactorials[k];
+      return LOG_FACTORIAL_TABLE[k];
     }
   }
 
@@ -447,13 +447,13 @@ public class Arithmetic extends Constant
    *
    * @param k must hold <tt>k &gt;= 0 && k &lt; 21</tt>.
    */
-  public static long longFactorial(int k) throws IllegalArgumentException {
+  public static long longFactorial(int k) {
     if (k < 0) {
       throw new IllegalArgumentException("Negative k");
     }
 
-    if (k < longFactorials.length) {
-      return longFactorials[k];
+    if (k < FACTORIAL_TABLE.length) {
+      return FACTORIAL_TABLE[k];
     }
     throw new IllegalArgumentException("Overflow");
   }
@@ -469,13 +469,13 @@ public class Arithmetic extends Constant
     if (k > 30) {
       double r = 1.0 / (double) k;
       double rr = r * r;
-      double C7 = -5.95238095238095238e-04;     //  -1/1680
-      double C5 = 7.93650793650793651e-04;     //  +1/1260
-      double C3 = -2.77777777777777778e-03;     //  -1/360
-      double C1 = 8.33333333333333333e-02;     //  +1/12
-      return r * (C1 + rr * (C3 + rr * (C5 + rr * C7)));
+      double c7 = -5.95238095238095238e-04;     //  -1/1680
+      double c5 = 7.93650793650793651e-04;     //  +1/1260
+      double c3 = -2.77777777777777778e-03;     //  -1/360
+      double c1 = 8.33333333333333333e-02;     //  +1/12
+      return r * (c1 + rr * (c3 + rr * (c5 + rr * c7)));
     } else {
-      return stirlingCorrection[k];
+      return STIRLING_CORRECTION_TABLE[k];
     }
   }
 

Modified: mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/math/Bessel.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/math/Bessel.java?rev=985582&r1=985581&r2=985582&view=diff
==============================================================================
--- mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/math/Bessel.java (original)
+++ mahout/trunk/math/src/main/java/org/apache/mahout/math/jet/math/Bessel.java Sat Aug 14 21:19:02 2010
@@ -24,37 +24,37 @@ public class Bessel extends Constants {
    *
    * lim(x->0){ exp(-x) I0(x) } = 1.
    */
-  protected static final double[] A_i0 = {
-      -4.41534164647933937950E-18,
-      3.33079451882223809783E-17,
-      -2.43127984654795469359E-16,
-      1.71539128555513303061E-15,
-      -1.16853328779934516808E-14,
-      7.67618549860493561688E-14,
-      -4.85644678311192946090E-13,
-      2.95505266312963983461E-12,
-      -1.72682629144155570723E-11,
-      9.67580903537323691224E-11,
-      -5.18979560163526290666E-10,
-      2.65982372468238665035E-9,
-      -1.30002500998624804212E-8,
-      6.04699502254191894932E-8,
-      -2.67079385394061173391E-7,
-      1.11738753912010371815E-6,
-      -4.41673835845875056359E-6,
-      1.64484480707288970893E-5,
-      -5.75419501008210370398E-5,
-      1.88502885095841655729E-4,
-      -5.76375574538582365885E-4,
-      1.63947561694133579842E-3,
-      -4.32430999505057594430E-3,
-      1.05464603945949983183E-2,
-      -2.37374148058994688156E-2,
-      4.93052842396707084878E-2,
-      -9.49010970480476444210E-2,
-      1.71620901522208775349E-1,
-      -3.04682672343198398683E-1,
-      6.76795274409476084995E-1
+  protected static final double[] aSubI0 = {
+    -4.41534164647933937950E-18,
+    3.33079451882223809783E-17,
+    -2.43127984654795469359E-16,
+    1.71539128555513303061E-15,
+    -1.16853328779934516808E-14,
+    7.67618549860493561688E-14,
+    -4.85644678311192946090E-13,
+    2.95505266312963983461E-12,
+    -1.72682629144155570723E-11,
+    9.67580903537323691224E-11,
+    -5.18979560163526290666E-10,
+    2.65982372468238665035E-9,
+    -1.30002500998624804212E-8,
+    6.04699502254191894932E-8,
+    -2.67079385394061173391E-7,
+    1.11738753912010371815E-6,
+    -4.41673835845875056359E-6,
+    1.64484480707288970893E-5,
+    -5.75419501008210370398E-5,
+    1.88502885095841655729E-4,
+    -5.76375574538582365885E-4,
+    1.63947561694133579842E-3,
+    -4.32430999505057594430E-3,
+    1.05464603945949983183E-2,
+    -2.37374148058994688156E-2,
+    4.93052842396707084878E-2,
+    -9.49010970480476444210E-2,
+    1.71620901522208775349E-1,
+    -3.04682672343198398683E-1,
+    6.76795274409476084995E-1
   };
 
 
@@ -63,32 +63,32 @@ public class Bessel extends Constants {
    *
    * lim(x->inf){ exp(-x) sqrt(x) I0(x) } = 1/sqrt(2pi).
    */
-  protected static final double[] B_i0 = {
-      -7.23318048787475395456E-18,
-      -4.83050448594418207126E-18,
-      4.46562142029675999901E-17,
-      3.46122286769746109310E-17,
-      -2.82762398051658348494E-16,
-      -3.42548561967721913462E-16,
-      1.77256013305652638360E-15,
-      3.81168066935262242075E-15,
-      -9.55484669882830764870E-15,
-      -4.15056934728722208663E-14,
-      1.54008621752140982691E-14,
-      3.85277838274214270114E-13,
-      7.18012445138366623367E-13,
-      -1.79417853150680611778E-12,
-      -1.32158118404477131188E-11,
-      -3.14991652796324136454E-11,
-      1.18891471078464383424E-11,
-      4.94060238822496958910E-10,
-      3.39623202570838634515E-9,
-      2.26666899049817806459E-8,
-      2.04891858946906374183E-7,
-      2.89137052083475648297E-6,
-      6.88975834691682398426E-5,
-      3.36911647825569408990E-3,
-      8.04490411014108831608E-1
+  protected static final double[] bSubI0 = {
+    -7.23318048787475395456E-18,
+    -4.83050448594418207126E-18,
+    4.46562142029675999901E-17,
+    3.46122286769746109310E-17,
+    -2.82762398051658348494E-16,
+    -3.42548561967721913462E-16,
+    1.77256013305652638360E-15,
+    3.81168066935262242075E-15,
+    -9.55484669882830764870E-15,
+    -4.15056934728722208663E-14,
+    1.54008621752140982691E-14,
+    3.85277838274214270114E-13,
+    7.18012445138366623367E-13,
+    -1.79417853150680611778E-12,
+    -1.32158118404477131188E-11,
+    -3.14991652796324136454E-11,
+    1.18891471078464383424E-11,
+    4.94060238822496958910E-10,
+    3.39623202570838634515E-9,
+    2.26666899049817806459E-8,
+    2.04891858946906374183E-7,
+    2.89137052083475648297E-6,
+    6.88975834691682398426E-5,
+    3.36911647825569408990E-3,
+    8.04490411014108831608E-1
   };
 
 
@@ -100,36 +100,36 @@ public class Bessel extends Constants {
    *
    * lim(x->0){ exp(-x) I1(x) / x } = 1/2.
    */
-  protected static final double[] A_i1 = {
-      2.77791411276104639959E-18,
-      -2.11142121435816608115E-17,
-      1.55363195773620046921E-16,
-      -1.10559694773538630805E-15,
-      7.60068429473540693410E-15,
-      -5.04218550472791168711E-14,
-      3.22379336594557470981E-13,
-      -1.98397439776494371520E-12,
-      1.17361862988909016308E-11,
-      -6.66348972350202774223E-11,
-      3.62559028155211703701E-10,
-      -1.88724975172282928790E-9,
-      9.38153738649577178388E-9,
-      -4.44505912879632808065E-8,
-      2.00329475355213526229E-7,
-      -8.56872026469545474066E-7,
-      3.47025130813767847674E-6,
-      -1.32731636560394358279E-5,
-      4.78156510755005422638E-5,
-      -1.61760815825896745588E-4,
-      5.12285956168575772895E-4,
-      -1.51357245063125314899E-3,
-      4.15642294431288815669E-3,
-      -1.05640848946261981558E-2,
-      2.47264490306265168283E-2,
-      -5.29459812080949914269E-2,
-      1.02643658689847095384E-1,
-      -1.76416518357834055153E-1,
-      2.52587186443633654823E-1
+  protected static final double[] aSubI1 = {
+    2.77791411276104639959E-18,
+    -2.11142121435816608115E-17,
+    1.55363195773620046921E-16,
+    -1.10559694773538630805E-15,
+    7.60068429473540693410E-15,
+    -5.04218550472791168711E-14,
+    3.22379336594557470981E-13,
+    -1.98397439776494371520E-12,
+    1.17361862988909016308E-11,
+    -6.66348972350202774223E-11,
+    3.62559028155211703701E-10,
+    -1.88724975172282928790E-9,
+    9.38153738649577178388E-9,
+    -4.44505912879632808065E-8,
+    2.00329475355213526229E-7,
+    -8.56872026469545474066E-7,
+    3.47025130813767847674E-6,
+    -1.32731636560394358279E-5,
+    4.78156510755005422638E-5,
+    -1.61760815825896745588E-4,
+    5.12285956168575772895E-4,
+    -1.51357245063125314899E-3,
+    4.15642294431288815669E-3,
+    -1.05640848946261981558E-2,
+    2.47264490306265168283E-2,
+    -5.29459812080949914269E-2,
+    1.02643658689847095384E-1,
+    -1.76416518357834055153E-1,
+    2.52587186443633654823E-1
   };
 
   /*
@@ -138,32 +138,32 @@ public class Bessel extends Constants {
    *
    * lim(x->inf){ exp(-x) sqrt(x) I1(x) } = 1/sqrt(2pi).
    */
-  protected static final double[] B_i1 = {
-      7.51729631084210481353E-18,
-      4.41434832307170791151E-18,
-      -4.65030536848935832153E-17,
-      -3.20952592199342395980E-17,
-      2.96262899764595013876E-16,
-      3.30820231092092828324E-16,
-      -1.88035477551078244854E-15,
-      -3.81440307243700780478E-15,
-      1.04202769841288027642E-14,
-      4.27244001671195135429E-14,
-      -2.10154184277266431302E-14,
-      -4.08355111109219731823E-13,
-      -7.19855177624590851209E-13,
-      2.03562854414708950722E-12,
-      1.41258074366137813316E-11,
-      3.25260358301548823856E-11,
-      -1.89749581235054123450E-11,
-      -5.58974346219658380687E-10,
-      -3.83538038596423702205E-9,
-      -2.63146884688951950684E-8,
-      -2.51223623787020892529E-7,
-      -3.88256480887769039346E-6,
-      -1.10588938762623716291E-4,
-      -9.76109749136146840777E-3,
-      7.78576235018280120474E-1
+  protected static final double[] bSubI1 = {
+    7.51729631084210481353E-18,
+    4.41434832307170791151E-18,
+    -4.65030536848935832153E-17,
+    -3.20952592199342395980E-17,
+    2.96262899764595013876E-16,
+    3.30820231092092828324E-16,
+    -1.88035477551078244854E-15,
+    -3.81440307243700780478E-15,
+    1.04202769841288027642E-14,
+    4.27244001671195135429E-14,
+    -2.10154184277266431302E-14,
+    -4.08355111109219731823E-13,
+    -7.19855177624590851209E-13,
+    2.03562854414708950722E-12,
+    1.41258074366137813316E-11,
+    3.25260358301548823856E-11,
+    -1.89749581235054123450E-11,
+    -5.58974346219658380687E-10,
+    -3.83538038596423702205E-9,
+    -2.63146884688951950684E-8,
+    -2.51223623787020892529E-7,
+    -3.88256480887769039346E-6,
+    -1.10588938762623716291E-4,
+    -9.76109749136146840777E-3,
+    7.78576235018280120474E-1
   };
 
 
@@ -174,17 +174,17 @@ public class Bessel extends Constants {
    * 
    * lim(x->0){ K0(x) + log(x/2) I0(x) } = -EUL.
    */
-  protected static final double[] A_k0 = {
-      1.37446543561352307156E-16,
-      4.25981614279661018399E-14,
-      1.03496952576338420167E-11,
-      1.90451637722020886025E-9,
-      2.53479107902614945675E-7,
-      2.28621210311945178607E-5,
-      1.26461541144692592338E-3,
-      3.59799365153615016266E-2,
-      3.44289899924628486886E-1,
-      -5.35327393233902768720E-1
+  protected static final double[] aSubK0 = {
+    1.37446543561352307156E-16,
+    4.25981614279661018399E-14,
+    1.03496952576338420167E-11,
+    1.90451637722020886025E-9,
+    2.53479107902614945675E-7,
+    2.28621210311945178607E-5,
+    1.26461541144692592338E-3,
+    3.59799365153615016266E-2,
+    3.44289899924628486886E-1,
+    -5.35327393233902768720E-1
   };
 
   /* Chebyshev coefficients for exp(x) sqrt(x) K0(x)
@@ -192,32 +192,32 @@ public class Bessel extends Constants {
    * 
    * lim(x->inf){ exp(x) sqrt(x) K0(x) } = sqrt(pi/2).
    */
-  protected static final double[] B_k0 = {
-      5.30043377268626276149E-18,
-      -1.64758043015242134646E-17,
-      5.21039150503902756861E-17,
-      -1.67823109680541210385E-16,
-      5.51205597852431940784E-16,
-      -1.84859337734377901440E-15,
-      6.34007647740507060557E-15,
-      -2.22751332699166985548E-14,
-      8.03289077536357521100E-14,
-      -2.98009692317273043925E-13,
-      1.14034058820847496303E-12,
-      -4.51459788337394416547E-12,
-      1.85594911495471785253E-11,
-      -7.95748924447710747776E-11,
-      3.57739728140030116597E-10,
-      -1.69753450938905987466E-9,
-      8.57403401741422608519E-9,
-      -4.66048989768794782956E-8,
-      2.76681363944501510342E-7,
-      -1.83175552271911948767E-6,
-      1.39498137188764993662E-5,
-      -1.28495495816278026384E-4,
-      1.56988388573005337491E-3,
-      -3.14481013119645005427E-2,
-      2.44030308206595545468E0
+  protected static final double[] bSubK0 = {
+    5.30043377268626276149E-18,
+    -1.64758043015242134646E-17,
+    5.21039150503902756861E-17,
+    -1.67823109680541210385E-16,
+    5.51205597852431940784E-16,
+    -1.84859337734377901440E-15,
+    6.34007647740507060557E-15,
+    -2.22751332699166985548E-14,
+    8.03289077536357521100E-14,
+    -2.98009692317273043925E-13,
+    1.14034058820847496303E-12,
+    -4.51459788337394416547E-12,
+    1.85594911495471785253E-11,
+    -7.95748924447710747776E-11,
+    3.57739728140030116597E-10,
+    -1.69753450938905987466E-9,
+    8.57403401741422608519E-9,
+    -4.66048989768794782956E-8,
+    2.76681363944501510342E-7,
+    -1.83175552271911948767E-6,
+    1.39498137188764993662E-5,
+    -1.28495495816278026384E-4,
+    1.56988388573005337491E-3,
+    -3.14481013119645005427E-2,
+    2.44030308206595545468E0
   };
 
 
@@ -227,18 +227,18 @@ public class Bessel extends Constants {
    * 
    * lim(x->0){ x(K1(x) - log(x/2) I1(x)) } = 1.
    */
-  protected static final double[] A_k1 = {
-      -7.02386347938628759343E-18,
-      -2.42744985051936593393E-15,
-      -6.66690169419932900609E-13,
-      -1.41148839263352776110E-10,
-      -2.21338763073472585583E-8,
-      -2.43340614156596823496E-6,
-      -1.73028895751305206302E-4,
-      -6.97572385963986435018E-3,
-      -1.22611180822657148235E-1,
-      -3.53155960776544875667E-1,
-      1.52530022733894777053E0
+  protected static final double[] aSubK1 = {
+    -7.02386347938628759343E-18,
+    -2.42744985051936593393E-15,
+    -6.66690169419932900609E-13,
+    -1.41148839263352776110E-10,
+    -2.21338763073472585583E-8,
+    -2.43340614156596823496E-6,
+    -1.73028895751305206302E-4,
+    -6.97572385963986435018E-3,
+    -1.22611180822657148235E-1,
+    -3.53155960776544875667E-1,
+    1.52530022733894777053E0
   };
 
   /* Chebyshev coefficients for exp(x) sqrt(x) K1(x)
@@ -246,33 +246,34 @@ public class Bessel extends Constants {
    *
    * lim(x->inf){ exp(x) sqrt(x) K1(x) } = sqrt(pi/2).
    */
-  protected static final double[] B_k1 = {
-      -5.75674448366501715755E-18,
-      1.79405087314755922667E-17,
-      -5.68946255844285935196E-17,
-      1.83809354436663880070E-16,
-      -6.05704724837331885336E-16,
-      2.03870316562433424052E-15,
-      -7.01983709041831346144E-15,
-      2.47715442448130437068E-14,
-      -8.97670518232499435011E-14,
-      3.34841966607842919884E-13,
-      -1.28917396095102890680E-12,
-      5.13963967348173025100E-12,
-      -2.12996783842756842877E-11,
-      9.21831518760500529508E-11,
-      -4.19035475934189648750E-10,
-      2.01504975519703286596E-9,
-      -1.03457624656780970260E-8,
-      5.74108412545004946722E-8,
-      -3.50196060308781257119E-7,
-      2.40648494783721712015E-6,
-      -1.93619797416608296024E-5,
-      1.95215518471351631108E-4,
-      -2.85781685962277938680E-3,
-      1.03923736576817238437E-1,
-      2.72062619048444266945E0
+  protected static final double[] bSubK1 = {
+    -5.75674448366501715755E-18,
+    1.79405087314755922667E-17,
+    -5.68946255844285935196E-17,
+    1.83809354436663880070E-16,
+    -6.05704724837331885336E-16,
+    2.03870316562433424052E-15,
+    -7.01983709041831346144E-15,
+    2.47715442448130437068E-14,
+    -8.97670518232499435011E-14,
+    3.34841966607842919884E-13,
+    -1.28917396095102890680E-12,
+    5.13963967348173025100E-12,
+    -2.12996783842756842877E-11,
+    9.21831518760500529508E-11,
+    -4.19035475934189648750E-10,
+    2.01504975519703286596E-9,
+    -1.03457624656780970260E-8,
+    5.74108412545004946722E-8,
+    -3.50196060308781257119E-7,
+    2.40648494783721712015E-6,
+    -1.93619797416608296024E-5,
+    1.95215518471351631108E-4,
+    -2.85781685962277938680E-3,
+    1.03923736576817238437E-1,
+    2.72062619048444266945E0
   };
+  private static final double EULER_GAMMA = 5.772156649015328606065e-1;
 
   /** Makes this class non instantiable, but still let's others inherit from it. */
   protected Bessel() {
@@ -285,16 +286,15 @@ public class Bessel extends Constants {
    *
    * @param x the value to compute the bessel function of.
    */
-  public static double i0(double x) throws ArithmeticException {
+  public static double i0(double x) {
     if (x < 0) {
       x = -x;
     }
     if (x <= 8.0) {
-      double y = (x / 2.0) - 2.0;
-      return (Math.exp(x) * Arithmetic.chbevl(y, A_i0, 30));
+      return (Math.exp(x) * Arithmetic.chbevl((x / 2.0) - 2.0, aSubI0, 30));
     }
 
-    return (Math.exp(x) * Arithmetic.chbevl(32.0 / x - 2.0, B_i0, 25) / Math.sqrt(x));
+    return Math.exp(x) * Arithmetic.chbevl(32.0 / x - 2.0, bSubI0, 25) / Math.sqrt(x);
   }
 
   /**
@@ -303,17 +303,16 @@ public class Bessel extends Constants {
    *
    * @param x the value to compute the bessel function of.
    */
-  public static double i0e(double x) throws ArithmeticException {
+  public static double i0e(double x) {
 
     if (x < 0) {
       x = -x;
     }
     if (x <= 8.0) {
-      double y = (x / 2.0) - 2.0;
-      return (Arithmetic.chbevl(y, A_i0, 30));
+      return (Arithmetic.chbevl((x / 2.0) - 2.0, aSubI0, 30));
     }
 
-    return (Arithmetic.chbevl(32.0 / x - 2.0, B_i0, 25) / Math.sqrt(x));
+    return Arithmetic.chbevl(32.0 / x - 2.0, bSubI0, 25) / Math.sqrt(x);
   }
 
   /**
@@ -323,19 +322,18 @@ public class Bessel extends Constants {
    *
    * @param x the value to compute the bessel function of.
    */
-  public static double i1(double x) throws ArithmeticException {
+  public static double i1(double x) {
 
     double z = Math.abs(x);
     if (z <= 8.0) {
-      double y = (z / 2.0) - 2.0;
-      z = Arithmetic.chbevl(y, A_i1, 29) * z * Math.exp(z);
+      z = Arithmetic.chbevl((z / 2.0) - 2.0, aSubI1, 29) * z * Math.exp(z);
     } else {
-      z = Math.exp(z) * Arithmetic.chbevl(32.0 / z - 2.0, B_i1, 25) / Math.sqrt(z);
+      z = Math.exp(z) * Arithmetic.chbevl(32.0 / z - 2.0, bSubI1, 25) / Math.sqrt(z);
     }
     if (x < 0.0) {
       z = -z;
     }
-    return (z);
+    return z;
   }
 
   /**
@@ -344,19 +342,18 @@ public class Bessel extends Constants {
    *
    * @param x the value to compute the bessel function of.
    */
-  public static double i1e(double x) throws ArithmeticException {
+  public static double i1e(double x) {
 
     double z = Math.abs(x);
     if (z <= 8.0) {
-      double y = (z / 2.0) - 2.0;
-      z = Arithmetic.chbevl(y, A_i1, 29) * z;
+      z = Arithmetic.chbevl((z / 2.0) - 2.0, aSubI1, 29) * z;
     } else {
-      z = Arithmetic.chbevl(32.0 / z - 2.0, B_i1, 25) / Math.sqrt(z);
+      z = Arithmetic.chbevl(32.0 / z - 2.0, bSubI1, 25) / Math.sqrt(z);
     }
     if (x < 0.0) {
       z = -z;
     }
-    return (z);
+    return z;
   }
 
   /**
@@ -364,7 +361,7 @@ public class Bessel extends Constants {
    *
    * @param x the value to compute the bessel function of.
    */
-  public static double j0(double x) throws ArithmeticException {
+  public static double j0(double x) {
     double ax;
 
     if ((ax = Math.abs(x)) < 8.0) {
@@ -386,8 +383,7 @@ public class Bessel extends Constants {
           + y * (-0.6911147651e-5 + y * (0.7621095161e-6
           - y * 0.934935152e-7)));
 
-      return Math.sqrt(0.636619772 / ax) *
-          (Math.cos(xx) * ans1 - z * Math.sin(xx) * ans2);
+      return Math.sqrt(0.636619772 / ax) * (Math.cos(xx) * ans1 - z * Math.sin(xx) * ans2);
     }
   }
 
@@ -396,7 +392,7 @@ public class Bessel extends Constants {
    *
    * @param x the value to compute the bessel function of.
    */
-  public static double j1(double x) throws ArithmeticException {
+  public static double j1(double x) {
     double ax;
     double y;
     double ans1;
@@ -419,8 +415,7 @@ public class Bessel extends Constants {
       ans2 = 0.04687499995 + y * (-0.2002690873e-3
           + y * (0.8449199096e-5 + y * (-0.88228987e-6
           + y * 0.105787412e-6)));
-      double ans = Math.sqrt(0.636619772 / ax) *
-          (Math.cos(xx) * ans1 - z * Math.sin(xx) * ans2);
+      double ans = Math.sqrt(0.636619772 / ax) * (Math.cos(xx) * ans1 - z * Math.sin(xx) * ans2);
       if (x < 0.0) {
         ans = -ans;
       }
@@ -434,7 +429,7 @@ public class Bessel extends Constants {
    * @param n the order of the Bessel function.
    * @param x the value to compute the bessel function of.
    */
-  public static double jn(int n, double x) throws ArithmeticException {
+  public static double jn(int n, double x) {
 
     if (n == 0) {
       return j0(x);
@@ -466,23 +461,23 @@ public class Bessel extends Constants {
       ans = bj;
     } else {
       tox = 2.0 / ax;
-      double ACC = 40.0;
-      int m = 2 * ((n + (int) Math.sqrt(ACC * n)) / 2);
+      double acc = 40.0;
+      int m = 2 * ((n + (int) Math.sqrt(acc * n)) / 2);
       double sum;
       bjp = ans = sum = 0.0;
       bj = 1.0;
-      double BIGNI = 1.0e-10;
-      double BIGNO = 1.0e+10;
+      double bigni = 1.0e-10;
+      double bigno = 1.0e+10;
       boolean jsum = false;
       for (j = m; j > 0; j--) {
         bjm = j * tox * bj - bjp;
         bjp = bj;
         bj = bjm;
-        if (Math.abs(bj) > BIGNO) {
-          bj *= BIGNI;
-          bjp *= BIGNI;
-          ans *= BIGNI;
-          sum *= BIGNI;
+        if (Math.abs(bj) > bigno) {
+          bj *= bigni;
+          bjp *= bigni;
+          ans *= bigni;
+          sum *= bigni;
         }
         if (jsum) {
           sum += bj;
@@ -504,21 +499,19 @@ public class Bessel extends Constants {
    *
    * @param x the value to compute the bessel function of.
    */
-  public static double k0(double x) throws ArithmeticException {
+  public static double k0(double x) {
 
     if (x <= 0.0) {
       throw new ArithmeticException();
     }
     double y;
     if (x <= 2.0) {
-      y = x * x - 2.0;
-      y = Arithmetic.chbevl(y, A_k0, 10) - Math.log(0.5 * x) * i0(x);
-      return (y);
+      return Arithmetic.chbevl(x * x - 2.0, aSubK0, 10) - Math.log(0.5 * x) * i0(x);
     }
 
     double z = 8.0 / x - 2.0;
-    y = Math.exp(-x) * Arithmetic.chbevl(z, B_k0, 25) / Math.sqrt(x);
-    return (y);
+    y = Math.exp(-x) * Arithmetic.chbevl(z, bSubK0, 25) / Math.sqrt(x);
+    return y;
   }
 
   /**
@@ -526,20 +519,16 @@ public class Bessel extends Constants {
    *
    * @param x the value to compute the bessel function of.
    */
-  public static double k0e(double x) throws ArithmeticException {
+  public static double k0e(double x) {
 
     if (x <= 0.0) {
       throw new ArithmeticException();
     }
-    double y;
     if (x <= 2.0) {
-      y = x * x - 2.0;
-      y = Arithmetic.chbevl(y, A_k0, 10) - Math.log(0.5 * x) * i0(x);
-      return (y * Math.exp(x));
+      return (Arithmetic.chbevl(x * x - 2.0, aSubK0, 10) - Math.log(0.5 * x) * i0(x)) * Math.exp(x);
     }
 
-    y = Arithmetic.chbevl(8.0 / x - 2.0, B_k0, 25) / Math.sqrt(x);
-    return (y);
+    return Arithmetic.chbevl(8.0 / x - 2.0, bSubK0, 25) / Math.sqrt(x);
   }
 
   /**
@@ -548,19 +537,17 @@ public class Bessel extends Constants {
    *
    * @param x the value to compute the bessel function of.
    */
-  public static double k1(double x) throws ArithmeticException {
+  public static double k1(double x) {
 
     double z = 0.5 * x;
     if (z <= 0.0) {
       throw new ArithmeticException();
     }
     if (x <= 2.0) {
-      double y = x * x - 2.0;
-      y = Math.log(z) * i1(x) + Arithmetic.chbevl(y, A_k1, 11) / x;
-      return (y);
+      return Math.log(z) * i1(x) + Arithmetic.chbevl(x * x - 2.0, aSubK1, 11) / x;
     }
 
-    return (Math.exp(-x) * Arithmetic.chbevl(8.0 / x - 2.0, B_k1, 25) / Math.sqrt(x));
+    return Math.exp(-x) * Arithmetic.chbevl(8.0 / x - 2.0, bSubK1, 25) / Math.sqrt(x);
   }
 
   /**
@@ -569,18 +556,16 @@ public class Bessel extends Constants {
    *
    * @param x the value to compute the bessel function of.
    */
-  public static double k1e(double x) throws ArithmeticException {
+  public static double k1e(double x) {
 
     if (x <= 0.0) {
       throw new ArithmeticException();
     }
     if (x <= 2.0) {
-      double y = x * x - 2.0;
-      y = Math.log(0.5 * x) * i1(x) + Arithmetic.chbevl(y, A_k1, 11) / x;
-      return (y * Math.exp(x));
+      return (Math.log(0.5 * x) * i1(x) + Arithmetic.chbevl(x * x - 2.0, aSubK1, 11) / x) * Math.exp(x);
     }
 
-    return (Arithmetic.chbevl(8.0 / x - 2.0, B_k1, 25) / Math.sqrt(x));
+    return Arithmetic.chbevl(8.0 / x - 2.0, bSubK1, 25) / Math.sqrt(x);
   }
 
   /**
@@ -591,7 +576,7 @@ public class Bessel extends Constants {
    * @param nn the order of the Bessel function.
    * @param x  the value to compute the bessel function of.
    */
-  public static double kn(int nn, double x) throws ArithmeticException {
+  public static double kn(int nn, double x) {
 /*
 Algorithm for Kn.
              n-1 
@@ -630,8 +615,8 @@ asymptotically, where
 
     int n = nn < 0 ? -nn : nn;
 
-    int MAXFAC = 31;
-    if (n > MAXFAC) {
+    int maxFactorial = 31;
+    if (n > maxFactorial) {
       throw new ArithmeticException("Overflow");
     }
     if (x <= 0.0) {
@@ -649,7 +634,6 @@ asymptotically, where
     double t;
     double nk1f;
     double k;
-    double MAXNUM = Double.MAX_VALUE;
     if (x <= 9.55) {
       ans = 0.0;
       z0 = 0.25 * x * x;
@@ -658,10 +642,9 @@ asymptotically, where
       double zmn = 1.0;
       double tox = 2.0 / x;
 
-      double EUL = 5.772156649015328606065e-1;
       if (n > 0) {
         /* compute factorial of n and psi(n) */
-        pn = -EUL;
+        pn = -EULER_GAMMA;
         k = 1.0;
         for (i = 1; i < n; i++) {
           pn += 1.0 / k;
@@ -680,25 +663,25 @@ asymptotically, where
           double zn = 1.0;
           double kf = 1.0;
           for (i = 1; i < n; i++) {
-            nk1f /= (n - i);
+            nk1f /= n - i;
             kf *= i;
             zn *= z;
             t = nk1f * zn / kf;
             s += t;
-            if ((MAXNUM - Math.abs(t)) < Math.abs(s)) {
+            if ((Double.MAX_VALUE - Math.abs(t)) < Math.abs(s)) {
               throw new ArithmeticException("Overflow");
             }
-            if ((tox > 1.0) && ((MAXNUM / tox) < zmn)) {
+            if ((tox > 1.0) && ((Double.MAX_VALUE / tox) < zmn)) {
               throw new ArithmeticException("Overflow");
             }
             zmn *= tox;
           }
           s *= 0.5;
           t = Math.abs(s);
-          if ((zmn > 1.0) && ((MAXNUM / zmn) < t)) {
+          if ((zmn > 1.0) && ((Double.MAX_VALUE / zmn) < t)) {
             throw new ArithmeticException("Overflow");
           }
-          if ((t > 1.0) && ((MAXNUM / t) < zmn)) {
+          if ((t > 1.0) && ((Double.MAX_VALUE / t) < zmn)) {
             throw new ArithmeticException("Overflow");
           }
           ans = s * zmn;
@@ -707,7 +690,7 @@ asymptotically, where
 
 
       double tlg = 2.0 * Math.log(0.5 * x);
-      pk = -EUL;
+      pk = -EULER_GAMMA;
       if (n == 0) {
         pn = pk;
         t = 1.0;
@@ -732,7 +715,7 @@ asymptotically, where
       }
       ans += s;
 
-      return (ans);
+      return ans;
     }
 
 
@@ -748,7 +731,7 @@ asymptotically, where
     fn = 1.0;
     t = 1.0;
     s = t;
-    double nkf = MAXNUM;
+    double nkf = Double.MAX_VALUE;
     i = 0;
     do {
       z = pn - pk * pk;
@@ -766,8 +749,7 @@ asymptotically, where
     } while (Math.abs(t / s) > MACHEP);
 
 
-    ans = Math.exp(-x) * Math.sqrt(Math.PI / (2.0 * x)) * s;
-    return (ans);
+    return Math.exp(-x) * Math.sqrt(Math.PI / (2.0 * x)) * s;
   }
 
   /**
@@ -775,7 +757,7 @@ asymptotically, where
    *
    * @param x the value to compute the bessel function of.
    */
-  public static double y0(double x) throws ArithmeticException {
+  public static double y0(double x) {
     if (x < 8.0) {
       double y = x * x;
       double ans1 = -2957821389.0 + y * (7062834065.0 + y * (-512359803.6
@@ -794,8 +776,7 @@ asymptotically, where
       double ans2 = -0.1562499995e-1 + y * (0.1430488765e-3
           + y * (-0.6911147651e-5 + y * (0.7621095161e-6
           + y * (-0.934945152e-7))));
-      return Math.sqrt(0.636619772 / x) *
-          (Math.sin(xx) * ans1 + z * Math.cos(xx) * ans2);
+      return Math.sqrt(0.636619772 / x) * (Math.sin(xx) * ans1 + z * Math.cos(xx) * ans2);
     }
   }
 
@@ -804,7 +785,7 @@ asymptotically, where
    *
    * @param x the value to compute the bessel function of.
    */
-  public static double y1(double x) throws ArithmeticException {
+  public static double y1(double x) {
     if (x < 8.0) {
       double y = x * x;
       double ans1 = x * (-0.4900604943e13 + y * (0.1275274390e13
@@ -823,8 +804,7 @@ asymptotically, where
       double ans2 = 0.04687499995 + y * (-0.2002690873e-3
           + y * (0.8449199096e-5 + y * (-0.88228987e-6
           + y * 0.105787412e-6)));
-      return Math.sqrt(0.636619772 / x) *
-          (Math.sin(xx) * ans1 + z * Math.cos(xx) * ans2);
+      return Math.sqrt(0.636619772 / x) * (Math.sin(xx) * ans1 + z * Math.cos(xx) * ans2);
     }
   }
 
@@ -834,7 +814,7 @@ asymptotically, where
    * @param n the order of the Bessel function.
    * @param x the value to compute the bessel function of.
    */
-  public static double yn(int n, double x) throws ArithmeticException {
+  public static double yn(int n, double x) {
 
     if (n == 0) {
       return y0(x);