jdk/test/java/lang/Math/HyperbolicTests.java
author mchung
Fri, 22 Aug 2014 14:56:09 -0700
changeset 26197 1bb6b68b87cd
parent 23010 6dadb192ad81
permissions -rw-r--r--
8042003: Update java/lang/Math tests to eliminate dependency on sun.misc.DoubleConsts and sun.misc.FloatConsts Reviewed-by: mchung, darcy Contributed-by: amy.lu@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 14856
diff changeset
     2
 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     4
 *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     7
 * published by the Free Software Foundation.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     8
 *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    13
 * accompanied this code).
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    14
 *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1826
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1826
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1826
diff changeset
    21
 * questions.
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    22
 */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    23
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    24
/*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    25
 * @test
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    26
 * @bug 4851625 4900189 4939441
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    27
 * @summary Tests for {Math, StrictMath}.{sinh, cosh, tanh}
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    28
 * @author Joseph D. Darcy
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    29
 */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    30
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    31
public class HyperbolicTests {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    32
    private HyperbolicTests(){}
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    33
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    34
    static final double NaNd = Double.NaN;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    35
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    36
    /**
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    37
     * Test accuracy of {Math, StrictMath}.sinh.  The specified
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    38
     * accuracy is 2.5 ulps.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    39
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    40
     * The defintion of sinh(x) is
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    41
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    42
     * (e^x - e^(-x))/2
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    43
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    44
     * The series expansion of sinh(x) =
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    45
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    46
     * x + x^3/3! + x^5/5! + x^7/7! +...
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    47
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    48
     * Therefore,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    49
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    50
     * 1. For large values of x sinh(x) ~= signum(x)*exp(|x|)/2
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    51
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    52
     * 2. For small values of x, sinh(x) ~= x.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    53
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    54
     * Additionally, sinh is an odd function; sinh(-x) = -sinh(x).
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    55
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    56
     */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    57
    static int testSinh() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    58
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    59
        /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    60
         * Array elements below generated using a quad sinh
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    61
         * implementation.  Rounded to a double, the quad result
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    62
         * *should* be correctly rounded, unless we are quite unlucky.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    63
         * Assuming the quad value is a correctly rounded double, the
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    64
         * allowed error is 3.0 ulps instead of 2.5 since the quad
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    65
         * value rounded to double can have its own 1/2 ulp error.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    66
         */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    67
        double [][] testCases = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    68
            // x                sinh(x)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    69
            {0.0625,            0.06254069805219182172183988501029229},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    70
            {0.1250,            0.12532577524111545698205754229137154},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    71
            {0.1875,            0.18860056562029018382047025055167585},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    72
            {0.2500,            0.25261231680816830791412515054205787},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    73
            {0.3125,            0.31761115611357728583959867611490292},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    74
            {0.3750,            0.38385106791361456875429567642050245},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    75
            {0.4375,            0.45159088610312053032509815226723017},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    76
            {0.5000,            0.52109530549374736162242562641149155},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    77
            {0.5625,            0.59263591611468777373870867338492247},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    78
            {0.6250,            0.66649226445661608227260655608302908},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    79
            {0.6875,            0.74295294580567543571442036910465007},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    80
            {0.7500,            0.82231673193582998070366163444691386},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    81
            {0.8125,            0.90489373856606433650504536421491368},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    82
            {0.8750,            0.99100663714429475605317427568995231},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    83
            {0.9375,            1.08099191569306394011007867453992548},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    84
            {1.0000,            1.17520119364380145688238185059560082},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    85
            {1.0625,            1.27400259579739321279181130344911907},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    86
            {1.1250,            1.37778219077984075760379987065228373},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    87
            {1.1875,            1.48694549961380717221109202361777593},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    88
            {1.2500,            1.60191908030082563790283030151221415},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    89
            {1.3125,            1.72315219460596010219069206464391528},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    90
            {1.3750,            1.85111856355791532419998548438506416},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    91
            {1.4375,            1.98631821852425112898943304217629457},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    92
            {1.5000,            2.12927945509481749683438749467763195},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    93
            {1.5625,            2.28056089740825247058075476705718764},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    94
            {1.6250,            2.44075368098794353221372986997161132},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    95
            {1.6875,            2.61048376261693140366028569794027603},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    96
            {1.7500,            2.79041436627764265509289122308816092},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    97
            {1.8125,            2.98124857471401377943765253243875520},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    98
            {1.8750,            3.18373207674259205101326780071803724},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    99
            {1.9375,            3.39865608104779099764440244167531810},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   100
            {2.0000,            3.62686040784701876766821398280126192},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   101
            {2.0625,            3.86923677050642806693938384073620450},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   102
            {2.1250,            4.12673225993027252260441410537905269},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   103
            {2.1875,            4.40035304533919660406976249684469164},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   104
            {2.2500,            4.69116830589833069188357567763552003},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   105
            {2.3125,            5.00031440855811351554075363240262157},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   106
            {2.3750,            5.32899934843284576394645856548481489},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   107
            {2.4375,            5.67850746906785056212578751630266858},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   108
            {2.5000,            6.05020448103978732145032363835040319},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   109
            {2.5625,            6.44554279850040875063706020260185553},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   110
            {2.6250,            6.86606721451642172826145238779845813},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   111
            {2.6875,            7.31342093738196587585692115636603571},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   112
            {2.7500,            7.78935201149073201875513401029935330},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   113
            {2.8125,            8.29572014785741787167717932988491961},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   114
            {2.8750,            8.83450399097893197351853322827892144},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   115
            {2.9375,            9.40780885043076394429977972921690859},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   116
            {3.0000,            10.01787492740990189897459361946582867},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   117
            {3.0625,            10.66708606836969224165124519209968368},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   118
            {3.1250,            11.35797907995166028304704128775698426},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   119
            {3.1875,            12.09325364161259019614431093344260209},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   120
            {3.2500,            12.87578285468067003959660391705481220},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   121
            {3.3125,            13.70862446906136798063935858393686525},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   122
            {3.3750,            14.59503283146163690015482636921657975},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   123
            {3.4375,            15.53847160182039311025096666980558478},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   124
            {3.5000,            16.54262728763499762495673152901249743},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   125
            {3.5625,            17.61142364906941482858466494889121694},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   126
            {3.6250,            18.74903703113232171399165788088277979},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   127
            {3.6875,            19.95991268283598684128844120984214675},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   128
            {3.7500,            21.24878212710338697364101071825171163},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   129
            {3.8125,            22.62068164929685091969259499078125023},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   130
            {3.8750,            24.08097197661255803883403419733891573},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   131
            {3.9375,            25.63535922523855307175060244757748997},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   132
            {4.0000,            27.28991719712775244890827159079382096},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   133
            {4.0625,            29.05111111351106713777825462100160185},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   134
            {4.1250,            30.92582287788986031725487699744107092},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   135
            {4.1875,            32.92137796722343190618721270937061472},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   136
            {4.2500,            35.04557405638942942322929652461901154},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   137
            {4.3125,            37.30671148776788628118833357170042385},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   138
            {4.3750,            39.71362570500944929025069048612806024},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   139
            {4.4375,            42.27572177772344954814418332587050658},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   140
            {4.5000,            45.00301115199178562180965680564371424},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   141
            {4.5625,            47.90615077031205065685078058248081891},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   142
            {4.6250,            50.99648471383193131253995134526177467},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   143
            {4.6875,            54.28608852959281437757368957713936555},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   144
            {4.7500,            57.78781641599226874961859781628591635},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   145
            {4.8125,            61.51535145084362283008545918273109379},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   146
            {4.8750,            65.48325905829987165560146562921543361},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   147
            {4.9375,            69.70704392356508084094318094283346381},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   148
            {5.0000,            74.20321057778875897700947199606456364},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   149
            {5.0625,            78.98932788987998983462810080907521151},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   150
            {5.1250,            84.08409771724448958901392613147384951},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   151
            {5.1875,            89.50742798369883598816307922895346849},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   152
            {5.2500,            95.28051047011540739630959111303975956},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   153
            {5.3125,            101.42590362176666730633859252034238987},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   154
            {5.3750,            107.96762069594029162704530843962700133},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   155
            {5.4375,            114.93122359426386042048760580590182604},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   156
            {5.5000,            122.34392274639096192409774240457730721},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   157
            {5.5625,            130.23468343534638291488502321709913206},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   158
            {5.6250,            138.63433897999898233879574111119546728},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   159
            {5.6875,            147.57571121692522056519568264304815790},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   160
            {5.7500,            157.09373875244884423880085377625986165},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   161
            {5.8125,            167.22561348600435888568183143777868662},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   162
            {5.8750,            178.01092593829229887752609866133883987},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   163
            {5.9375,            189.49181995209921964640216682906501778},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   164
            {6.0000,            201.71315737027922812498206768797872263},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   165
            {6.0625,            214.72269333437984291483666459592578915},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   166
            {6.1250,            228.57126288889537420461281285729970085},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   167
            {6.1875,            243.31297962030799867970551767086092471},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   168
            {6.2500,            259.00544710710289911522315435345489966},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   169
            {6.3125,            275.70998400700299790136562219920451185},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   170
            {6.3750,            293.49186366095654566861661249898332253},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   171
            {6.4375,            312.42056915013535342987623229485223434},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   172
            {6.5000,            332.57006480258443156075705566965111346},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   173
            {6.5625,            354.01908521044116928437570109827956007},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   174
            {6.6250,            376.85144288706511933454985188849781703},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   175
            {6.6875,            401.15635576625530823119100750634165252},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   176
            {6.7500,            427.02879582326538080306830640235938517},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   177
            {6.8125,            454.56986017986077163530945733572724452},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   178
            {6.8750,            483.88716614351897894746751705315210621},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   179
            {6.9375,            515.09527172439720070161654727225752288},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   180
            {7.0000,            548.31612327324652237375611757601851598},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   181
            {7.0625,            583.67953198942753384680988096024373270},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   182
            {7.1250,            621.32368116099280160364794462812762880},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   183
            {7.1875,            661.39566611888784148449430491465857519},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   184
            {7.2500,            704.05206901515336623551137120663358760},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   185
            {7.3125,            749.45957067108712382864538206200700256},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   186
            {7.3750,            797.79560188617531521347351754559776282},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   187
            {7.4375,            849.24903675279739482863565789325699416},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   188
            {7.5000,            904.02093068584652953510919038935849651},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   189
            {7.5625,            962.32530605113249628368993221570636328},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   190
            {7.6250,            1024.38998846242707559349318193113614698},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   191
            {7.6875,            1090.45749701500081956792547346904792325},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   192
            {7.7500,            1160.78599193425808533255719118417856088},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   193
            {7.8125,            1235.65028334242796895820912936318532502},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   194
            {7.8750,            1315.34290508508890654067255740428824014},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   195
            {7.9375,            1400.17525781352742299995139486063802583},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   196
            {8.0000,            1490.47882578955018611587663903188144796},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   197
            {8.0625,            1586.60647216744061169450001100145859236},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   198
            {8.1250,            1688.93381781440241350635231605477507900},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   199
            {8.1875,            1797.86070905726094477721128358866360644},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   200
            {8.2500,            1913.81278009067446281883262689250118009},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   201
            {8.3125,            2037.24311615199935553277163192983440062},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   202
            {8.3750,            2168.63402396170125867037749369723761636},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   203
            {8.4375,            2308.49891634734644432370720900969004306},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   204
            {8.5000,            2457.38431841538268239359965370719928775},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   205
            {8.5625,            2615.87200310986940554256648824234335262},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   206
            {8.6250,            2784.58126450289932429469130598902487336},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   207
            {8.6875,            2964.17133769964321637973459949999057146},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   208
            {8.7500,            3155.34397481384944060352507473513108710},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   209
            {8.8125,            3358.84618707947841898217318996045550438},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   210
            {8.8750,            3575.47316381333288862617411467285480067},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   211
            {8.9375,            3806.07137963459383403903729660349293583},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   212
            {9.0000,            4051.54190208278996051522359589803425598},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   213
            {9.0625,            4312.84391255878980330955246931164633615},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   214
            {9.1250,            4590.99845434696991399363282718106006883},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   215
            {9.1875,            4887.09242236403719571363798584676797558},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   216
            {9.2500,            5202.28281022453561319352901552085348309},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   217
            {9.3125,            5537.80123121853803935727335892054791265},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   218
            {9.3750,            5894.95873086734181634245918412592155656},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   219
            {9.4375,            6275.15090986233399457103055108344546942},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   220
            {9.5000,            6679.86337740502119410058225086262108741},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   221
            {9.5625,            7110.67755625726876329967852256934334025},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   222
            {9.6250,            7569.27686218510919585241049433331592115},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   223
            {9.6875,            8057.45328194243077504648484392156371121},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   224
            {9.7500,            8577.11437549816065709098061006273039092},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   225
            {9.8125,            9130.29072986829727910801024120918114778},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   226
            {9.8750,            9719.14389367880274015504995181862860062},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   227
            {9.9375,            10345.97482346383208590278839409938269134},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   228
            {10.0000,           11013.23287470339337723652455484636420303},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   229
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   230
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   231
        for(int i = 0; i < testCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   232
            double [] testCase = testCases[i];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   233
            failures += testSinhCaseWithUlpDiff(testCase[0],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   234
                                                testCase[1],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   235
                                                3.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   236
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   237
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   238
        double [][] specialTestCases = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   239
            {0.0,                       0.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   240
            {NaNd,                      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   241
            {Double.longBitsToDouble(0x7FF0000000000001L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   242
            {Double.longBitsToDouble(0xFFF0000000000001L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   243
            {Double.longBitsToDouble(0x7FF8555555555555L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   244
            {Double.longBitsToDouble(0xFFF8555555555555L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   245
            {Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   246
            {Double.longBitsToDouble(0xFFFFFFFFFFFFFFFFL),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   247
            {Double.longBitsToDouble(0x7FFDeadBeef00000L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   248
            {Double.longBitsToDouble(0xFFFDeadBeef00000L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   249
            {Double.longBitsToDouble(0x7FFCafeBabe00000L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   250
            {Double.longBitsToDouble(0xFFFCafeBabe00000L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   251
            {Double.POSITIVE_INFINITY,  Double.POSITIVE_INFINITY}
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   252
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   253
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   254
        for(int i = 0; i < specialTestCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   255
            failures += testSinhCaseWithUlpDiff(specialTestCases[i][0],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   256
                                                specialTestCases[i][1],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   257
                                                0.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   258
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   259
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   260
        // For powers of 2 less than 2^(-27), the second and
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   261
        // subsequent terms of the Taylor series expansion will get
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   262
        // rounded away since |n-n^3| > 53, the binary precision of a
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   263
        // double significand.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   264
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   265
        for(int i = DoubleConsts.MIN_SUB_EXPONENT; i < -27; i++) {
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
   266
            double d = Math.scalb(2.0, i);
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   267
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   268
            // Result and expected are the same.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   269
            failures += testSinhCaseWithUlpDiff(d, d, 2.5);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   270
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   271
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   272
        // For values of x larger than 22, the e^(-x) term is
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   273
        // insignificant to the floating-point result.  Util exp(x)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   274
        // overflows around 709.8, sinh(x) ~= exp(x)/2; will will test
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   275
        // 10000 values in this range.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   276
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   277
        long trans22 = Double.doubleToLongBits(22.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   278
        // (approximately) largest value such that exp shouldn't
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   279
        // overflow
10608
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   280
        long transExpOvfl = Double.doubleToLongBits(Math.nextDown(709.7827128933841));
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   281
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   282
        for(long i = trans22;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   283
            i < transExpOvfl;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   284
            i +=(transExpOvfl-trans22)/10000) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   285
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   286
            double d = Double.longBitsToDouble(i);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   287
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   288
            // Allow 3.5 ulps of error to deal with error in exp.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   289
            failures += testSinhCaseWithUlpDiff(d, StrictMath.exp(d)*0.5, 3.5);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   290
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   291
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   292
        // (approximately) largest value such that sinh shouldn't
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   293
        // overflow.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   294
        long transSinhOvfl = Double.doubleToLongBits(710.4758600739439);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   295
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   296
        // Make sure sinh(x) doesn't overflow as soon as exp(x)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   297
        // overflows.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   298
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   299
        /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   300
         * For large values of x, sinh(x) ~= 0.5*(e^x).  Therefore,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   301
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   302
         * sinh(x) ~= e^(ln 0.5) * e^x = e^(x + ln 0.5)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   303
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   304
         * So, we can calculate the approximate expected result as
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   305
         * exp(x + -0.693147186).  However, this sum suffers from
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   306
         * roundoff, limiting the accuracy of the approximation.  The
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   307
         * accuracy can be improved by recovering the rounded-off
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   308
         * information.  Since x is larger than ln(0.5), the trailing
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   309
         * bits of ln(0.5) get rounded away when the two values are
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   310
         * added.  However, high-order bits of ln(0.5) that
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   311
         * contribute to the sum can be found:
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   312
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   313
         * offset = log(0.5);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   314
         * effective_offset = (x + offset) - x; // exact subtraction
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   315
         * rounded_away_offset = offset - effective_offset; // exact subtraction
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   316
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   317
         * Therefore, the product
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   318
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   319
         * exp(x + offset)*exp(rounded_away_offset)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   320
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   321
         * will be a better approximation to the exact value of
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   322
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   323
         * e^(x + offset)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   324
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   325
         * than exp(x+offset) alone.  (The expected result cannot be
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   326
         * computed as exp(x)*exp(offset) since exp(x) by itself would
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   327
         * overflow to infinity.)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   328
         */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   329
        double offset = StrictMath.log(0.5);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   330
        for(long i = transExpOvfl+1; i < transSinhOvfl;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   331
            i += (transSinhOvfl-transExpOvfl)/1000 ) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   332
            double input = Double.longBitsToDouble(i);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   333
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   334
            double expected =
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   335
                StrictMath.exp(input + offset) *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   336
                StrictMath.exp( offset - ((input + offset) - input) );
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   337
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   338
            failures += testSinhCaseWithUlpDiff(input, expected, 4.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   339
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   340
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   341
        // sinh(x) overflows for values greater than 710; in
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   342
        // particular, it overflows for all 2^i, i > 10.
26197
1bb6b68b87cd 8042003: Update java/lang/Math tests to eliminate dependency on sun.misc.DoubleConsts and sun.misc.FloatConsts
mchung
parents: 23010
diff changeset
   343
        for(int i = 10; i <= Double.MAX_EXPONENT; i++) {
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
   344
            double d = Math.scalb(2.0, i);
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   345
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   346
            // Result and expected are the same.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   347
            failures += testSinhCaseWithUlpDiff(d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   348
                                                Double.POSITIVE_INFINITY, 0.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   349
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   350
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   351
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   352
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   353
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   354
    public static int testSinhCaseWithTolerance(double input,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   355
                                                double expected,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   356
                                                double tolerance) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   357
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   358
        failures += Tests.testTolerance("Math.sinh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   359
                                        input, Math.sinh(input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   360
                                        expected, tolerance);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   361
        failures += Tests.testTolerance("Math.sinh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   362
                                        -input, Math.sinh(-input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   363
                                        -expected, tolerance);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   364
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   365
        failures += Tests.testTolerance("StrictMath.sinh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   366
                                        input, StrictMath.sinh(input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   367
                                        expected, tolerance);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   368
        failures += Tests.testTolerance("StrictMath.sinh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   369
                                        -input, StrictMath.sinh(-input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   370
                                        -expected, tolerance);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   371
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   372
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   373
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   374
    public static int testSinhCaseWithUlpDiff(double input,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   375
                                              double expected,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   376
                                              double ulps) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   377
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   378
        failures += Tests.testUlpDiff("Math.sinh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   379
                                      input, Math.sinh(input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   380
                                      expected, ulps);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   381
        failures += Tests.testUlpDiff("Math.sinh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   382
                                      -input, Math.sinh(-input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   383
                                      -expected, ulps);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   384
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   385
        failures += Tests.testUlpDiff("StrictMath.sinh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   386
                                      input, StrictMath.sinh(input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   387
                                      expected, ulps);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   388
        failures += Tests.testUlpDiff("StrictMath.sinh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   389
                                      -input, StrictMath.sinh(-input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   390
                                      -expected, ulps);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   391
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   392
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   393
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   394
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   395
    /**
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   396
     * Test accuracy of {Math, StrictMath}.cosh.  The specified
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   397
     * accuracy is 2.5 ulps.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   398
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   399
     * The defintion of cosh(x) is
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   400
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   401
     * (e^x + e^(-x))/2
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   402
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   403
     * The series expansion of cosh(x) =
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   404
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   405
     * 1 + x^2/2! + x^4/4! + x^6/6! +...
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   406
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   407
     * Therefore,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   408
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   409
     * 1. For large values of x cosh(x) ~= exp(|x|)/2
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   410
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   411
     * 2. For small values of x, cosh(x) ~= 1.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   412
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   413
     * Additionally, cosh is an even function; cosh(-x) = cosh(x).
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   414
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   415
     */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   416
    static int testCosh() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   417
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   418
        /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   419
         * Array elements below generated using a quad cosh
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   420
         * implementation.  Rounded to a double, the quad result
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   421
         * *should* be correctly rounded, unless we are quite unlucky.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   422
         * Assuming the quad value is a correctly rounded double, the
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   423
         * allowed error is 3.0 ulps instead of 2.5 since the quad
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   424
         * value rounded to double can have its own 1/2 ulp error.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   425
         */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   426
        double [][] testCases = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   427
            // x                cosh(x)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   428
            {0.0625,            1.001953760865667607841550709632597376},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   429
            {0.1250,            1.007822677825710859846949685520422223},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   430
            {0.1875,            1.017629683800690526835115759894757615},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   431
            {0.2500,            1.031413099879573176159295417520378622},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   432
            {0.3125,            1.049226785060219076999158096606305793},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   433
            {0.3750,            1.071140346704586767299498015567016002},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   434
            {0.4375,            1.097239412531012567673453832328262160},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   435
            {0.5000,            1.127625965206380785226225161402672030},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   436
            {0.5625,            1.162418740845610783505338363214045218},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   437
            {0.6250,            1.201753692975606324229229064105075301},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   438
            {0.6875,            1.245784523776616395403056980542275175},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   439
            {0.7500,            1.294683284676844687841708185390181730},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   440
            {0.8125,            1.348641048647144208352285714214372703},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   441
            {0.8750,            1.407868656822803158638471458026344506},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   442
            {0.9375,            1.472597542369862933336886403008640891},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   443
            {1.0000,            1.543080634815243778477905620757061497},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   444
            {1.0625,            1.619593348374367728682469968448090763},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   445
            {1.1250,            1.702434658138190487400868008124755757},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   446
            {1.1875,            1.791928268324866464246665745956119612},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   447
            {1.2500,            1.888423877161015738227715728160051696},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   448
            {1.3125,            1.992298543335143985091891077551921106},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   449
            {1.3750,            2.103958159362661802010972984204389619},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   450
            {1.4375,            2.223839037619709260803023946704272699},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   451
            {1.5000,            2.352409615243247325767667965441644201},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   452
            {1.5625,            2.490172284559350293104864895029231913},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   453
            {1.6250,            2.637665356192137582275019088061812951},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   454
            {1.6875,            2.795465162524235691253423614360562624},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   455
            {1.7500,            2.964188309728087781773608481754531801},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   456
            {1.8125,            3.144494087167972176411236052303565201},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   457
            {1.8750,            3.337087043587520514308832278928116525},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   458
            {1.9375,            3.542719740149244276729383650503145346},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   459
            {2.0000,            3.762195691083631459562213477773746099},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   460
            {2.0625,            3.996372503438463642260225717607554880},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   461
            {2.1250,            4.246165228196992140600291052990934410},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   462
            {2.1875,            4.512549935859540340856119781585096760},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   463
            {2.2500,            4.796567530460195028666793366876218854},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   464
            {2.3125,            5.099327816921939817643745917141739051},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   465
            {2.3750,            5.422013837643509250646323138888569746},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   466
            {2.4375,            5.765886495263270945949271410819116399},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   467
            {2.5000,            6.132289479663686116619852312817562517},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   468
            {2.5625,            6.522654518468725462969589397439224177},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   469
            {2.6250,            6.938506971550673190999796241172117288},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   470
            {2.6875,            7.381471791406976069645686221095397137},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   471
            {2.7500,            7.853279872697439591457564035857305647},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   472
            {2.8125,            8.355774815752725814638234943192709129},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   473
            {2.8750,            8.890920130482709321824793617157134961},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   474
            {2.9375,            9.460806908834119747071078865866737196},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   475
            {3.0000,            10.067661995777765841953936035115890343},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   476
            {3.0625,            10.713856690753651225304006562698007312},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   477
            {3.1250,            11.401916013575067700373788969458446177},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   478
            {3.1875,            12.134528570998387744547733730974713055},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   479
            {3.2500,            12.914557062512392049483503752322408761},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   480
            {3.3125,            13.745049466398732213877084541992751273},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   481
            {3.3750,            14.629250949773302934853381428660210721},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   482
            {3.4375,            15.570616549147269180921654324879141947},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   483
            {3.5000,            16.572824671057316125696517821376119469},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   484
            {3.5625,            17.639791465519127930722105721028711044},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   485
            {3.6250,            18.775686128468677200079039891415789429},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   486
            {3.6875,            19.984947192985946987799359614758598457},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   487
            {3.7500,            21.272299872959396081877161903352144126},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   488
            {3.8125,            22.642774526961913363958587775566619798},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   489
            {3.8750,            24.101726314486257781049388094955970560},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   490
            {3.9375,            25.654856121347151067170940701379544221},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   491
            {4.0000,            27.308232836016486629201989612067059978},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   492
            {4.0625,            29.068317063936918520135334110824828950},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   493
            {4.1250,            30.941986372478026192360480044849306606},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   494
            {4.1875,            32.936562165180269851350626768308756303},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   495
            {4.2500,            35.059838290298428678502583470475012235},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   496
            {4.3125,            37.320111495433027109832850313172338419},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   497
            {4.3750,            39.726213847251883288518263854094284091},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   498
            {4.4375,            42.287547242982546165696077854963452084},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   499
            {4.5000,            45.014120148530027928305799939930642658},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   500
            {4.5625,            47.916586706774825161786212701923307169},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   501
            {4.6250,            51.006288368867753140854830589583165950},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   502
            {4.6875,            54.295298211196782516984520211780624960},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   503
            {4.7500,            57.796468111195389383795669320243166117},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   504
            {4.8125,            61.523478966332915041549750463563672435},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   505
            {4.8750,            65.490894152518731617237739112888213645},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   506
            {4.9375,            69.714216430810089539924900313140922323},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   507
            {5.0000,            74.209948524787844444106108044487704798},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   508
            {5.0625,            78.995657605307475581204965926043112946},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   509
            {5.1250,            84.090043934600961683400343038519519678},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   510
            {5.1875,            89.513013937957834087706670952561002466},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   511
            {5.2500,            95.285757988514588780586084642381131013},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   512
            {5.3125,            101.430833209098212357990123684449846912},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   513
            {5.3750,            107.972251614673824873137995865940755392},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   514
            {5.4375,            114.935573939814969189535554289886848550},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   515
            {5.5000,            122.348009517829425991091207107262038316},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   516
            {5.5625,            130.238522601820409078244923165746295574},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   517
            {5.6250,            138.637945543134998069351279801575968875},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   518
            {5.6875,            147.579099269447055276899288971207106581},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   519
            {5.7500,            157.096921533245353905868840194264636395},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   520
            {5.8125,            167.228603431860671946045256541679445836},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   521
            {5.8750,            178.013734732486824390148614309727161925},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   522
            {5.9375,            189.494458570056311567917444025807275896},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   523
            {6.0000,            201.715636122455894483405112855409538488},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   524
            {6.0625,            214.725021906554080628430756558271312513},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   525
            {6.1250,            228.573450380013557089736092321068279231},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   526
            {6.1875,            243.315034578039208138752165587134488645},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   527
            {6.2500,            259.007377561239126824465367865430519592},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   528
            {6.3125,            275.711797500835732516530131577254654076},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   529
            {6.3750,            293.493567280752348242602902925987643443},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   530
            {6.4375,            312.422169552825597994104814531010579387},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   531
            {6.5000,            332.571568241777409133204438572983297292},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   532
            {6.5625,            354.020497560858198165985214519757890505},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   533
            {6.6250,            376.852769667496146326030849450983914197},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   534
            {6.6875,            401.157602161123700280816957271992998156},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   535
            {6.7500,            427.029966702886171977469256622451185850},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   536
            {6.8125,            454.570960119471524953536004647195906721},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   537
            {6.8750,            483.888199441157626584508920036981010995},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   538
            {6.9375,            515.096242417696720610477570797503766179},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   539
            {7.0000,            548.317035155212076889964120712102928484},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   540
            {7.0625,            583.680388623257719787307547662358502345},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   541
            {7.1250,            621.324485894002926216918634755431456031},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   542
            {7.1875,            661.396422095589629755266517362992812037},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   543
            {7.2500,            704.052779189542208784574955807004218856},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   544
            {7.3125,            749.460237818184878095966335081928645934},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   545
            {7.3750,            797.796228612873763671070863694973560629},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   546
            {7.4375,            849.249625508044731271830060572510241864},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   547
            {7.5000,            904.021483770216677368692292389446994987},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   548
            {7.5625,            962.325825625814651122171697031114091993},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   549
            {7.6250,            1024.390476557670599008492465853663578558},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   550
            {7.6875,            1090.457955538048482588540574008226583335},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   551
            {7.7500,            1160.786422676798661020094043586456606003},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   552
            {7.8125,            1235.650687987597295222707689125107720568},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   553
            {7.8750,            1315.343285214046776004329388551335841550},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   554
            {7.9375,            1400.175614911635999247504386054087931958},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   555
            {8.0000,            1490.479161252178088627715460421007179728},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   556
            {8.0625,            1586.606787305415349050508956232945539108},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   557
            {8.1250,            1688.934113859132470361718199038326340668},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   558
            {8.1875,            1797.860987165547537276364148450577336075},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   559
            {8.2500,            1913.813041349231764486365114317586148767},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   560
            {8.3125,            2037.243361581700856522236313401822532385},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   561
            {8.3750,            2168.634254521568851112005905503069409349},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   562
            {8.4375,            2308.499132938297821208734949028296170563},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   563
            {8.5000,            2457.384521883751693037774022640629666294},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   564
            {8.5625,            2615.872194250713123494312356053193077854},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   565
            {8.6250,            2784.581444063104750127653362960649823247},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   566
            {8.6875,            2964.171506380845754878370650565756538203},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   567
            {8.7500,            3155.344133275174556354775488913749659006},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   568
            {8.8125,            3358.846335940117183452010789979584950102},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   569
            {8.8750,            3575.473303654961482727206202358956274888},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   570
            {8.9375,            3806.071511003646460448021740303914939059},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   571
            {9.0000,            4051.542025492594047194773093534725371440},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   572
            {9.0625,            4312.844028491571841588188869958240355518},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   573
            {9.1250,            4590.998563255739769060078863130940205710},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   574
            {9.1875,            4887.092524674358252509551443117048351290},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   575
            {9.2500,            5202.282906336187674588222835339193136030},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   576
            {9.3125,            5537.801321507079474415176386655744387251},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   577
            {9.3750,            5894.958815685577062811620236195525504885},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   578
            {9.4375,            6275.150989541692149890530417987358096221},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   579
            {9.5000,            6679.863452256851081801173722051940058824},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   580
            {9.5625,            7110.677626574055535297758456126491707647},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   581
            {9.6250,            7569.276928241617224537226019600213961572},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   582
            {9.6875,            8057.453343996777301036241026375049070162},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   583
            {9.7500,            8577.114433792824387959788368429252257664},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   584
            {9.8125,            9130.290784631065880205118262838330689429},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   585
            {9.8750,            9719.143945123662919857326995631317996715},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   586
            {9.9375,            10345.974871791805753327922796701684092861},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   587
            {10.0000,           11013.232920103323139721376090437880844591},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   588
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   589
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   590
        for(int i = 0; i < testCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   591
            double [] testCase = testCases[i];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   592
            failures += testCoshCaseWithUlpDiff(testCase[0],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   593
                                                testCase[1],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   594
                                                3.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   595
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   596
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   597
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   598
        double [][] specialTestCases = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   599
            {0.0,                       1.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   600
            {NaNd,                      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   601
            {Double.longBitsToDouble(0x7FF0000000000001L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   602
            {Double.longBitsToDouble(0xFFF0000000000001L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   603
            {Double.longBitsToDouble(0x7FF8555555555555L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   604
            {Double.longBitsToDouble(0xFFF8555555555555L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   605
            {Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   606
            {Double.longBitsToDouble(0xFFFFFFFFFFFFFFFFL),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   607
            {Double.longBitsToDouble(0x7FFDeadBeef00000L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   608
            {Double.longBitsToDouble(0xFFFDeadBeef00000L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   609
            {Double.longBitsToDouble(0x7FFCafeBabe00000L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   610
            {Double.longBitsToDouble(0xFFFCafeBabe00000L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   611
            {Double.POSITIVE_INFINITY,  Double.POSITIVE_INFINITY}
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   612
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   613
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   614
        for(int i = 0; i < specialTestCases.length; i++ ) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   615
            failures += testCoshCaseWithUlpDiff(specialTestCases[i][0],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   616
                                                specialTestCases[i][1],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   617
                                                0.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   618
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   619
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   620
        // For powers of 2 less than 2^(-27), the second and
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   621
        // subsequent terms of the Taylor series expansion will get
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   622
        // rounded.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   623
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   624
        for(int i = DoubleConsts.MIN_SUB_EXPONENT; i < -27; i++) {
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
   625
            double d = Math.scalb(2.0, i);
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   626
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   627
            // Result and expected are the same.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   628
            failures += testCoshCaseWithUlpDiff(d, 1.0, 2.5);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   629
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   630
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   631
        // For values of x larger than 22, the e^(-x) term is
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   632
        // insignificant to the floating-point result.  Util exp(x)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   633
        // overflows around 709.8, cosh(x) ~= exp(x)/2; will will test
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   634
        // 10000 values in this range.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   635
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   636
        long trans22 = Double.doubleToLongBits(22.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   637
        // (approximately) largest value such that exp shouldn't
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   638
        // overflow
10608
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   639
        long transExpOvfl = Double.doubleToLongBits(Math.nextDown(709.7827128933841));
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   640
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   641
        for(long i = trans22;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   642
            i < transExpOvfl;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   643
            i +=(transExpOvfl-trans22)/10000) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   644
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   645
            double d = Double.longBitsToDouble(i);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   646
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   647
            // Allow 3.5 ulps of error to deal with error in exp.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   648
            failures += testCoshCaseWithUlpDiff(d, StrictMath.exp(d)*0.5, 3.5);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   649
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   650
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   651
        // (approximately) largest value such that cosh shouldn't
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   652
        // overflow.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   653
        long transCoshOvfl = Double.doubleToLongBits(710.4758600739439);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   654
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   655
        // Make sure sinh(x) doesn't overflow as soon as exp(x)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   656
        // overflows.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   657
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   658
        /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   659
         * For large values of x, cosh(x) ~= 0.5*(e^x).  Therefore,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   660
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   661
         * cosh(x) ~= e^(ln 0.5) * e^x = e^(x + ln 0.5)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   662
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   663
         * So, we can calculate the approximate expected result as
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   664
         * exp(x + -0.693147186).  However, this sum suffers from
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   665
         * roundoff, limiting the accuracy of the approximation.  The
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   666
         * accuracy can be improved by recovering the rounded-off
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   667
         * information.  Since x is larger than ln(0.5), the trailing
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   668
         * bits of ln(0.5) get rounded away when the two values are
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   669
         * added.  However, high-order bits of ln(0.5) that
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   670
         * contribute to the sum can be found:
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   671
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   672
         * offset = log(0.5);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   673
         * effective_offset = (x + offset) - x; // exact subtraction
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   674
         * rounded_away_offset = offset - effective_offset; // exact subtraction
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   675
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   676
         * Therefore, the product
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   677
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   678
         * exp(x + offset)*exp(rounded_away_offset)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   679
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   680
         * will be a better approximation to the exact value of
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   681
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   682
         * e^(x + offset)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   683
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   684
         * than exp(x+offset) alone.  (The expected result cannot be
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   685
         * computed as exp(x)*exp(offset) since exp(x) by itself would
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   686
         * overflow to infinity.)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   687
         */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   688
        double offset = StrictMath.log(0.5);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   689
        for(long i = transExpOvfl+1; i < transCoshOvfl;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   690
            i += (transCoshOvfl-transExpOvfl)/1000 ) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   691
            double input = Double.longBitsToDouble(i);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   692
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   693
            double expected =
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   694
                StrictMath.exp(input + offset) *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   695
                StrictMath.exp( offset - ((input + offset) - input) );
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   696
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   697
            failures += testCoshCaseWithUlpDiff(input, expected, 4.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   698
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   699
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   700
        // cosh(x) overflows for values greater than 710; in
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   701
        // particular, it overflows for all 2^i, i > 10.
26197
1bb6b68b87cd 8042003: Update java/lang/Math tests to eliminate dependency on sun.misc.DoubleConsts and sun.misc.FloatConsts
mchung
parents: 23010
diff changeset
   702
        for(int i = 10; i <= Double.MAX_EXPONENT; i++) {
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
   703
            double d = Math.scalb(2.0, i);
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   704
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   705
            // Result and expected are the same.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   706
            failures += testCoshCaseWithUlpDiff(d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   707
                                                Double.POSITIVE_INFINITY, 0.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   708
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   709
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   710
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   711
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   712
    public static int testCoshCaseWithTolerance(double input,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   713
                                                double expected,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   714
                                                double tolerance) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   715
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   716
        failures += Tests.testTolerance("Math.cosh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   717
                                        input, Math.cosh(input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   718
                                        expected, tolerance);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   719
        failures += Tests.testTolerance("Math.cosh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   720
                                        -input, Math.cosh(-input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   721
                                        expected, tolerance);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   722
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   723
        failures += Tests.testTolerance("StrictMath.cosh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   724
                                        input, StrictMath.cosh(input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   725
                                        expected, tolerance);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   726
        failures += Tests.testTolerance("StrictMath.cosh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   727
                                        -input, StrictMath.cosh(-input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   728
                                        expected, tolerance);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   729
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   730
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   731
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   732
    public static int testCoshCaseWithUlpDiff(double input,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   733
                                              double expected,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   734
                                              double ulps) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   735
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   736
        failures += Tests.testUlpDiff("Math.cosh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   737
                                      input, Math.cosh(input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   738
                                      expected, ulps);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   739
        failures += Tests.testUlpDiff("Math.cosh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   740
                                      -input, Math.cosh(-input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   741
                                      expected, ulps);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   742
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   743
        failures += Tests.testUlpDiff("StrictMath.cosh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   744
                                      input, StrictMath.cosh(input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   745
                                      expected, ulps);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   746
        failures += Tests.testUlpDiff("StrictMath.cosh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   747
                                      -input, StrictMath.cosh(-input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   748
                                      expected, ulps);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   749
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   750
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   751
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   752
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   753
    /**
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   754
     * Test accuracy of {Math, StrictMath}.tanh.  The specified
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   755
     * accuracy is 2.5 ulps.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   756
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   757
     * The defintion of tanh(x) is
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   758
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   759
     * (e^x - e^(-x))/(e^x + e^(-x))
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   760
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   761
     * The series expansion of tanh(x) =
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   762
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   763
     * x - x^3/3 + 2x^5/15 - 17x^7/315 + ...
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   764
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   765
     * Therefore,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   766
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   767
     * 1. For large values of x tanh(x) ~= signum(x)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   768
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   769
     * 2. For small values of x, tanh(x) ~= x.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   770
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   771
     * Additionally, tanh is an odd function; tanh(-x) = -tanh(x).
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   772
     *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   773
     */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   774
    static int testTanh() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   775
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   776
        /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   777
         * Array elements below generated using a quad sinh
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   778
         * implementation.  Rounded to a double, the quad result
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   779
         * *should* be correctly rounded, unless we are quite unlucky.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   780
         * Assuming the quad value is a correctly rounded double, the
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   781
         * allowed error is 3.0 ulps instead of 2.5 since the quad
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   782
         * value rounded to double can have its own 1/2 ulp error.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   783
         */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   784
        double [][] testCases = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   785
            // x                tanh(x)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   786
            {0.0625,            0.06241874674751251449014289119421133},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   787
            {0.1250,            0.12435300177159620805464727580589271},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   788
            {0.1875,            0.18533319990813951753211997502482787},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   789
            {0.2500,            0.24491866240370912927780113149101697},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   790
            {0.3125,            0.30270972933210848724239738970991712},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   791
            {0.3750,            0.35835739835078594631936023155315807},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   792
            {0.4375,            0.41157005567402245143207555859415687},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   793
            {0.5000,            0.46211715726000975850231848364367256},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   794
            {0.5625,            0.50982997373525658248931213507053130},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   795
            {0.6250,            0.55459972234938229399903909532308371},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   796
            {0.6875,            0.59637355547924233984437303950726939},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   797
            {0.7500,            0.63514895238728731921443435731249638},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   798
            {0.8125,            0.67096707420687367394810954721913358},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   799
            {0.8750,            0.70390560393662106058763026963135371},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   800
            {0.9375,            0.73407151960434149263991588052503660},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   801
            {1.0000,            0.76159415595576488811945828260479366},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   802
            {1.0625,            0.78661881210869761781941794647736081},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   803
            {1.1250,            0.80930107020178101206077047354332696},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   804
            {1.1875,            0.82980190998595952708572559629034476},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   805
            {1.2500,            0.84828363995751289761338764670750445},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   806
            {1.3125,            0.86490661772074179125443141102709751},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   807
            {1.3750,            0.87982669965198475596055310881018259},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   808
            {1.4375,            0.89319334040035153149249598745889365},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   809
            {1.5000,            0.90514825364486643824230369645649557},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   810
            {1.5625,            0.91582454416876231820084311814416443},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   811
            {1.6250,            0.92534622531174107960457166792300374},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   812
            {1.6875,            0.93382804322259173763570528576138652},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   813
            {1.7500,            0.94137553849728736226942088377163687},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   814
            {1.8125,            0.94808528560440629971240651310180052},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   815
            {1.8750,            0.95404526017994877009219222661968285},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   816
            {1.9375,            0.95933529331468249183399461756952555},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   817
            {2.0000,            0.96402758007581688394641372410092317},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   818
            {2.0625,            0.96818721657637057702714316097855370},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   819
            {2.1250,            0.97187274591350905151254495374870401},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   820
            {2.1875,            0.97513669829362836159665586901156483},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   821
            {2.2500,            0.97802611473881363992272924300618321},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   822
            {2.3125,            0.98058304703705186541999427134482061},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   823
            {2.3750,            0.98284502917257603002353801620158861},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   824
            {2.4375,            0.98484551746427837912703608465407824},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   825
            {2.5000,            0.98661429815143028888127603923734964},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   826
            {2.5625,            0.98817786228751240824802592958012269},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   827
            {2.6250,            0.98955974861288320579361709496051109},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   828
            {2.6875,            0.99078085564125158320311117560719312},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   829
            {2.7500,            0.99185972456820774534967078914285035},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   830
            {2.8125,            0.99281279483715982021711715899682324},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   831
            {2.8750,            0.99365463431502962099607366282699651},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   832
            {2.9375,            0.99439814606575805343721743822723671},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   833
            {3.0000,            0.99505475368673045133188018525548849},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   834
            {3.0625,            0.99563456710930963835715538507891736},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   835
            {3.1250,            0.99614653067334504917102591131792951},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   836
            {3.1875,            0.99659855517712942451966113109487039},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   837
            {3.2500,            0.99699763548652601693227592643957226},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   838
            {3.3125,            0.99734995516557367804571991063376923},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   839
            {3.3750,            0.99766097946988897037219469409451602},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   840
            {3.4375,            0.99793553792649036103161966894686844},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   841
            {3.5000,            0.99817789761119870928427335245061171},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   842
            {3.5625,            0.99839182812874152902001617480606320},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   843
            {3.6250,            0.99858065920179882368897879066418294},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   844
            {3.6875,            0.99874733168378115962760304582965538},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   845
            {3.7500,            0.99889444272615280096784208280487888},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   846
            {3.8125,            0.99902428575443546808677966295308778},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   847
            {3.8750,            0.99913888583735077016137617231569011},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   848
            {3.9375,            0.99924003097049627100651907919688313},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   849
            {4.0000,            0.99932929973906704379224334434172499},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   850
            {4.0625,            0.99940808577297384603818654530731215},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   851
            {4.1250,            0.99947761936180856115470576756499454},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   852
            {4.1875,            0.99953898655601372055527046497863955},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   853
            {4.2500,            0.99959314604388958696521068958989891},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   854
            {4.3125,            0.99964094406130644525586201091350343},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   855
            {4.3750,            0.99968312756179494813069349082306235},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   856
            {4.4375,            0.99972035584870534179601447812936151},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   857
            {4.5000,            0.99975321084802753654050617379050162},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   858
            {4.5625,            0.99978220617994689112771768489030236},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   859
            {4.6250,            0.99980779516900105210240981251048167},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   860
            {4.6875,            0.99983037791655283849546303868853396},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   861
            {4.7500,            0.99985030754497877753787358852000255},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   862
            {4.8125,            0.99986789571029070417475400133989992},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   863
            {4.8750,            0.99988341746867772271011794614780441},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   864
            {4.9375,            0.99989711557251558205051185882773206},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   865
            {5.0000,            0.99990920426259513121099044753447306},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   866
            {5.0625,            0.99991987261554158551063867262784721},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   867
            {5.1250,            0.99992928749851651137225712249720606},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   868
            {5.1875,            0.99993759617721206697530526661105307},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   869
            {5.2500,            0.99994492861777083305830639416802036},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   870
            {5.3125,            0.99995139951851344080105352145538345},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   871
            {5.3750,            0.99995711010315817210152906092289064},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   872
            {5.4375,            0.99996214970350792531554669737676253},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   873
            {5.5000,            0.99996659715630380963848952941756868},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   874
            {5.5625,            0.99997052203605101013786592945475432},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   875
            {5.6250,            0.99997398574306704793434088941484766},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   876
            {5.6875,            0.99997704246374583929961850444364696},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   877
            {5.7500,            0.99997974001803825215761760428815437},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   878
            {5.8125,            0.99998212060739040166557477723121777},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   879
            {5.8750,            0.99998422147482750993344503195672517},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   880
            {5.9375,            0.99998607548749972326220227464612338},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   881
            {6.0000,            0.99998771165079557056434885235523206},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   882
            {6.0625,            0.99998915556205996764518917496149338},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   883
            {6.1250,            0.99999042981101021976277974520745310},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   884
            {6.1875,            0.99999155433311068015449574811497719},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   885
            {6.2500,            0.99999254672143162687722782398104276},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   886
            {6.3125,            0.99999342250186907900400800240980139},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   887
            {6.3750,            0.99999419537602957780612639767025158},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   888
            {6.4375,            0.99999487743557848265406225515388994},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   889
            {6.5000,            0.99999547935140419285107893831698753},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   890
            {6.5625,            0.99999601054055694588617385671796346},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   891
            {6.6250,            0.99999647931357331502887600387959900},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   892
            {6.6875,            0.99999689300449080997594368612277442},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   893
            {6.7500,            0.99999725808558628431084200832778748},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   894
            {6.8125,            0.99999758026863294516387464046135924},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   895
            {6.8750,            0.99999786459425991170635407313276785},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   896
            {6.9375,            0.99999811551081218572759991597586905},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   897
            {7.0000,            0.99999833694394467173571641595066708},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   898
            {7.0625,            0.99999853235803894918375164252059190},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   899
            {7.1250,            0.99999870481040359014665019356422927},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   900
            {7.1875,            0.99999885699910593255108365463415411},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   901
            {7.2500,            0.99999899130518359709674536482047025},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   902
            {7.3125,            0.99999910982989611769943303422227663},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   903
            {7.3750,            0.99999921442759946591163427422888252},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   904
            {7.4375,            0.99999930673475777603853435094943258},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   905
            {7.5000,            0.99999938819554614875054970643513124},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   906
            {7.5625,            0.99999946008444508183970109263856958},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   907
            {7.6250,            0.99999952352618001331402589096040117},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   908
            {7.6875,            0.99999957951331792817413683491979752},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   909
            {7.7500,            0.99999962892179632633374697389145081},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   910
            {7.8125,            0.99999967252462750190604116210421169},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   911
            {7.8750,            0.99999971100399253750324718031574484},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   912
            {7.9375,            0.99999974496191422474977283863588658},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   913
            {8.0000,            0.99999977492967588981001883295636840},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   914
            {8.0625,            0.99999980137613348259726597081723424},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   915
            {8.1250,            0.99999982471505097353529823063673263},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   916
            {8.1875,            0.99999984531157382142423402736529911},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   917
            {8.2500,            0.99999986348794179107425910499030547},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   918
            {8.3125,            0.99999987952853049895833839645847571},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   919
            {8.3750,            0.99999989368430056302584289932834041},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   920
            {8.4375,            0.99999990617672396471542088609051728},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   921
            {8.5000,            0.99999991720124905211338798152800748},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   922
            {8.5625,            0.99999992693035839516545287745322387},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   923
            {8.6250,            0.99999993551626733394129009365703767},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   924
            {8.6875,            0.99999994309330543951799157347876934},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   925
            {8.7500,            0.99999994978001814614368429416607424},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   926
            {8.8125,            0.99999995568102143535399207289008504},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   927
            {8.8750,            0.99999996088863858914831986187674522},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   928
            {8.9375,            0.99999996548434461974481685677429908},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   929
            {9.0000,            0.99999996954004097447930211118358244},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   930
            {9.0625,            0.99999997311918045901919121395899372},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   931
            {9.1250,            0.99999997627775997868467948564005257},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   932
            {9.1875,            0.99999997906519662964368381583648379},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   933
            {9.2500,            0.99999998152510084671976114264303159},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   934
            {9.3125,            0.99999998369595870397054673668361266},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   935
            {9.3750,            0.99999998561173404286033236040150950},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   936
            {9.4375,            0.99999998730239984852716512979473289},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   937
            {9.5000,            0.99999998879440718770812040917618843},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   938
            {9.5625,            0.99999999011109904501789298212541698},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   939
            {9.6250,            0.99999999127307553219220251303121960},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   940
            {9.6875,            0.99999999229851618412119275358396363},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   941
            {9.7500,            0.99999999320346438410630581726217930},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   942
            {9.8125,            0.99999999400207836827291739324060736},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   943
            {9.8750,            0.99999999470685273619047001387577653},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   944
            {9.9375,            0.99999999532881393331131526966058758},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   945
            {10.0000,           0.99999999587769276361959283713827574},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   946
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   947
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   948
        for(int i = 0; i < testCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   949
            double [] testCase = testCases[i];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   950
            failures += testTanhCaseWithUlpDiff(testCase[0],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   951
                                                testCase[1],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   952
                                                3.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   953
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   954
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   955
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   956
        double [][] specialTestCases = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   957
            {0.0,                       0.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   958
            {NaNd,                      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   959
            {Double.longBitsToDouble(0x7FF0000000000001L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   960
            {Double.longBitsToDouble(0xFFF0000000000001L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   961
            {Double.longBitsToDouble(0x7FF8555555555555L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   962
            {Double.longBitsToDouble(0xFFF8555555555555L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   963
            {Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   964
            {Double.longBitsToDouble(0xFFFFFFFFFFFFFFFFL),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   965
            {Double.longBitsToDouble(0x7FFDeadBeef00000L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   966
            {Double.longBitsToDouble(0xFFFDeadBeef00000L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   967
            {Double.longBitsToDouble(0x7FFCafeBabe00000L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   968
            {Double.longBitsToDouble(0xFFFCafeBabe00000L),      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   969
            {Double.POSITIVE_INFINITY,  1.0}
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   970
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   971
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   972
        for(int i = 0; i < specialTestCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   973
            failures += testTanhCaseWithUlpDiff(specialTestCases[i][0],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   974
                                                specialTestCases[i][1],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   975
                                                0.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   976
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   977
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   978
        // For powers of 2 less than 2^(-27), the second and
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   979
        // subsequent terms of the Taylor series expansion will get
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   980
        // rounded away since |n-n^3| > 53, the binary precision of a
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   981
        // double significand.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   982
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   983
        for(int i = DoubleConsts.MIN_SUB_EXPONENT; i < -27; i++) {
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
   984
            double d = Math.scalb(2.0, i);
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   985
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   986
            // Result and expected are the same.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   987
            failures += testTanhCaseWithUlpDiff(d, d, 2.5);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   988
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   989
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   990
        // For values of x larger than 22, tanh(x) is 1.0 in double
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   991
        // floating-point arithmetic.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   992
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   993
        for(int i = 22; i < 32; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   994
            failures += testTanhCaseWithUlpDiff(i, 1.0, 2.5);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   995
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   996
26197
1bb6b68b87cd 8042003: Update java/lang/Math tests to eliminate dependency on sun.misc.DoubleConsts and sun.misc.FloatConsts
mchung
parents: 23010
diff changeset
   997
        for(int i = 5; i <= Double.MAX_EXPONENT; i++) {
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
   998
            double d = Math.scalb(2.0, i);
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   999
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1000
            failures += testTanhCaseWithUlpDiff(d, 1.0, 2.5);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1001
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1002
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1003
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1004
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1005
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1006
    public static int testTanhCaseWithTolerance(double input,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1007
                                                double expected,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1008
                                                double tolerance) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1009
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1010
        failures += Tests.testTolerance("Math.tanh(double",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1011
                                        input, Math.tanh(input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1012
                                        expected, tolerance);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1013
        failures += Tests.testTolerance("Math.tanh(double",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1014
                                        -input, Math.tanh(-input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1015
                                        -expected, tolerance);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1016
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1017
        failures += Tests.testTolerance("StrictMath.tanh(double",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1018
                                        input, StrictMath.tanh(input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1019
                                        expected, tolerance);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1020
        failures += Tests.testTolerance("StrictMath.tanh(double",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1021
                                        -input, StrictMath.tanh(-input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1022
                                        -expected, tolerance);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1023
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1024
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1025
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1026
    public static int testTanhCaseWithUlpDiff(double input,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1027
                                              double expected,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1028
                                              double ulps) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1029
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1030
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1031
        failures += Tests.testUlpDiffWithAbsBound("Math.tanh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1032
                                                  input, Math.tanh(input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1033
                                                  expected, ulps, 1.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1034
        failures += Tests.testUlpDiffWithAbsBound("Math.tanh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1035
                                                  -input, Math.tanh(-input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1036
                                                  -expected, ulps, 1.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1037
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1038
        failures += Tests.testUlpDiffWithAbsBound("StrictMath.tanh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1039
                                                  input, StrictMath.tanh(input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1040
                                                  expected, ulps, 1.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1041
        failures += Tests.testUlpDiffWithAbsBound("StrictMath.tanh(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1042
                                                  -input, StrictMath.tanh(-input),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1043
                                                  -expected, ulps, 1.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1044
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1045
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1046
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1047
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1048
    public static void main(String argv[]) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1049
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1050
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1051
        failures += testSinh();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1052
        failures += testCosh();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1053
        failures += testTanh();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1054
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1055
        if (failures > 0) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1056
            System.err.println("Testing the hyperbolic functions incurred "
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1057
                               + failures + " failures.");
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1058
            throw new RuntimeException();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1059
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1060
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1061
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1062
}