Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: test/mjsunit/es6/math-hyperbolic.js

Issue 522723002: Port fdlibm implementation for Math.cosh. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/math.js ('k') | third_party/fdlibm/fdlibm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 assertEquals(0, Math.acosh(1)); 95 assertEquals(0, Math.acosh(1));
96 assertEquals("Infinity", String(Math.acosh(Infinity))); 96 assertEquals("Infinity", String(Math.acosh(Infinity)));
97 97
98 // Math.acosh(x) is NaN for x < 1 98 // Math.acosh(x) is NaN for x < 1
99 [0.99999999999, 0.2, -1000, 0, -0].forEach(function(x) { 99 [0.99999999999, 0.2, -1000, 0, -0].forEach(function(x) {
100 assertTrue(isNaN(Math.acosh(x))); 100 assertTrue(isNaN(Math.acosh(x)));
101 }); 101 });
102 102
103 103
104 // Some random samples. 104 // Some random samples.
105 assertEqualsDelta(74.203210577788, Math.sinh(5), 1E-12); 105 assertEqualsDelta(74.20321057778875, Math.sinh(5), 1E-12);
106 assertEqualsDelta(-74.203210577788, Math.sinh(-5), 1E-12); 106 assertEqualsDelta(-74.20321057778875, Math.sinh(-5), 1E-12);
107 107
108 assertEqualsDelta(1.1276259652063, Math.cosh(0.5), 1E-12); 108 assertEqualsDelta(1.1276259652063807, Math.cosh(0.5), 1E-12);
109 assertEqualsDelta(74.209948524787, Math.cosh(5), 1E-12); 109 assertEqualsDelta(74.20994852478785, Math.cosh(5), 1E-12);
110 assertEqualsDelta(1.1276259652063, Math.cosh(-0.5), 1E-12); 110 assertEqualsDelta1.1276259652063807, Math.cosh(-0.5), 1E-12);
111 assertEqualsDelta(74.209948524787, Math.cosh(-5), 1E-12); 111 assertEqualsDelta(74.20994852478785, Math.cosh(-5), 1E-12);
112 112
113 assertEqualsDelta(0.4621171572600, Math.tanh(0.5), 1E-12); 113 assertEqualsDelta(0.4621171572600, Math.tanh(0.5), 1E-12);
114 assertEqualsDelta(0.9999092042625, Math.tanh(5), 1E-12); 114 assertEqualsDelta(0.9999092042625, Math.tanh(5), 1E-12);
115 assertEqualsDelta(-0.4621171572600, Math.tanh(-0.5), 1E-12); 115 assertEqualsDelta(-0.4621171572600, Math.tanh(-0.5), 1E-12);
116 assertEqualsDelta(-0.9999092042625, Math.tanh(-5), 1E-12); 116 assertEqualsDelta(-0.9999092042625, Math.tanh(-5), 1E-12);
117 117
118 assertEqualsDelta(0.4812118250596, Math.asinh(0.5), 1E-12); 118 assertEqualsDelta(0.4812118250596, Math.asinh(0.5), 1E-12);
119 assertEqualsDelta(2.3124383412727, Math.asinh(5), 1E-12); 119 assertEqualsDelta(2.3124383412727, Math.asinh(5), 1E-12);
120 assertEqualsDelta(-0.4812118250596, Math.asinh(-0.5), 1E-12); 120 assertEqualsDelta(-0.4812118250596, Math.asinh(-0.5), 1E-12);
121 assertEqualsDelta(-2.3124383412727, Math.asinh(-5), 1E-12); 121 assertEqualsDelta(-2.3124383412727, Math.asinh(-5), 1E-12);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 assertEquals(1.3440585709080678e43, Math.sinh(100)); 159 assertEquals(1.3440585709080678e43, Math.sinh(100));
160 assertEquals(-1.3440585709080678e43, Math.sinh(-100)); 160 assertEquals(-1.3440585709080678e43, Math.sinh(-100));
161 // No overflow, case |x| in [log(maxdouble), threshold] 161 // No overflow, case |x| in [log(maxdouble), threshold]
162 assertEquals(1.7976931348621744e308, Math.sinh(710.4758600739439)); 162 assertEquals(1.7976931348621744e308, Math.sinh(710.4758600739439));
163 assertEquals(-1.7976931348621744e308, Math.sinh(-710.4758600739439)); 163 assertEquals(-1.7976931348621744e308, Math.sinh(-710.4758600739439));
164 // Overflow, case |x| > threshold 164 // Overflow, case |x| > threshold
165 assertEquals(Infinity, Math.sinh(710.475860073944)); 165 assertEquals(Infinity, Math.sinh(710.475860073944));
166 assertEquals(-Infinity, Math.sinh(-710.475860073944)); 166 assertEquals(-Infinity, Math.sinh(-710.475860073944));
167 assertEquals(Infinity, Math.sinh(1000)); 167 assertEquals(Infinity, Math.sinh(1000));
168 assertEquals(-Infinity, Math.sinh(-1000)); 168 assertEquals(-Infinity, Math.sinh(-1000));
169
170 // Implementation-specific tests for cosh.
171 // Case |x| < 2^-55
172 assertEquals(1, Math.cosh(Math.pow(2, -56)));
173 assertEquals(1, Math.cosh(-Math.pow(2, -56)));
174 // Case |x| < 1/2*log(2). cosh(Math.LN2/4) = (sqrt(2)+1)/2^(5/4)
175 assertEquals(1.0150517651282178, Math.cosh(Math.LN2/4));
176 assertEquals(1.0150517651282178, Math.cosh(-Math.LN2/4));
177 // Case 1/2*log(2) < |x| < 22. cosh(10*Math.LN2) = 1048577/2048
178 assertEquals(512.00048828125, Math.cosh(10*Math.LN2));
179 assertEquals(512.00048828125, Math.cosh(-10*Math.LN2));
180 // Case 22 <= |x| < log(maxdouble)
181 assertEquals(2.1474836479999983e9, Math.cosh(32*Math.LN2));
182 assertEquals(2.1474836479999983e9, Math.cosh(-32*Math.LN2));
183 // Case log(maxdouble) <= |x| <= overflowthreshold
184 assertEquals(1.7976931348621744e308, Math.cosh(710.4758600739439));
185 assertEquals(1.7976931348621744e308, Math.cosh(-710.4758600739439));
186 // Overflow.
187 assertEquals(Infinity, Math.cosh(710.475860073944));
188 assertEquals(Infinity, Math.cosh(-710.475860073944));
OLDNEW
« no previous file with comments | « src/math.js ('k') | third_party/fdlibm/fdlibm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698