9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 4851638 4939441
27 * @summary Tests for {Math, StrictMath}.log1p
28 * @author Joseph D. Darcy
29 */
30
31 public class Log1pTests {
32 private Log1pTests(){}
33
34 static final double infinityD = Double.POSITIVE_INFINITY;
35 static final double NaNd = Double.NaN;
36
37 /**
38 * Formulation taken from HP-15C Advanced Functions Handbook, part
39 * number HP 0015-90011, p 181. This is accurate to a few ulps.
40 */
41 static double hp15cLogp(double x) {
42 double u = 1.0 + x;
43 return (u==1.0? x : StrictMath.log(u)*x/(u-1) );
44 }
45
46 /*
47 * The Taylor expansion of ln(1 + x) for -1 < x <= 1 is:
48 *
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 4851638 4939441
27 * @summary Tests for {Math, StrictMath}.log1p
28 * @author Joseph D. Darcy
29 * @key randomness
30 */
31
32 public class Log1pTests {
33 private Log1pTests(){}
34
35 static final double infinityD = Double.POSITIVE_INFINITY;
36 static final double NaNd = Double.NaN;
37
38 /**
39 * Formulation taken from HP-15C Advanced Functions Handbook, part
40 * number HP 0015-90011, p 181. This is accurate to a few ulps.
41 */
42 static double hp15cLogp(double x) {
43 double u = 1.0 + x;
44 return (u==1.0? x : StrictMath.log(u)*x/(u-1) );
45 }
46
47 /*
48 * The Taylor expansion of ln(1 + x) for -1 < x <= 1 is:
49 *
|