This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-numbers.git
The following commit(s) were added to refs/heads/master by this push: new 7cbee90 Move the data from the CReferenceTest to test resources. 7cbee90 is described below commit 7cbee90fb91da2182107aee2d3b4ff6b980a9ddf Author: Alex Herbert <aherb...@apache.org> AuthorDate: Mon Dec 9 23:17:41 2019 +0000 Move the data from the CReferenceTest to test resources. There are currently some cases of incorrect computations that are commented out using a ';' character in the test data: acos.txt:;0.5 0.0 1.0471975511965979 -0.0 acos.txt:;-0.5 -0.0 2.0943951023931953 0.0 acosh.txt:;0.5 0.0 0.0 1.0471975511965979 acosh.txt:;-0.5 -0.0 0.0 -2.0943951023931953 asinh.txt:;0.0 0.5 0.0 0.52359877559829893 atanh.txt:;1 0.0 Infinity 0.78539816339744828 --- .../commons/numbers/complex/CReferenceTest.java | 432 ++++----------------- .../apache/commons/numbers/complex/TestUtils.java | 162 +++++--- .../src/test/resources/data/acos.txt | 243 ++++++++++++ .../src/test/resources/data/acosh.txt | 243 ++++++++++++ .../src/test/resources/data/asinh.txt | 122 ++++++ .../src/test/resources/data/atanh.txt | 122 ++++++ .../src/test/resources/data/cosh.txt | 122 ++++++ .../src/test/resources/data/divide.txt | 17 + .../src/test/resources/data/exp.txt | 243 ++++++++++++ .../src/test/resources/data/log.txt | 243 ++++++++++++ .../src/test/resources/data/multiply.txt | 17 + .../src/test/resources/data/pow.txt | 17 + .../src/test/resources/data/sinh.txt | 122 ++++++ .../src/test/resources/data/sqrt.txt | 243 ++++++++++++ .../src/test/resources/data/tanh.txt | 122 ++++++ pom.xml | 3 +- 16 files changed, 2068 insertions(+), 405 deletions(-) diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CReferenceTest.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CReferenceTest.java index 662a972..57822b8 100644 --- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CReferenceTest.java +++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/CReferenceTest.java @@ -20,6 +20,7 @@ package org.apache.commons.numbers.complex; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import java.util.List; import java.util.function.BiFunction; import java.util.function.Supplier; import java.util.function.UnaryOperator; @@ -28,13 +29,22 @@ import java.util.function.UnaryOperator; * Tests the functions defined by the C.99 standard for complex numbers * defined in ISO/IEC 9899, Annex G. * - * <p>The test data is generated from a known implementation of the standard: GNU g++. + * <p>The test data is generated from a known implementation of the standard + * and saved to the test resources data files. * * @see <a href="http://www.open-std.org/JTC1/SC22/WG14/www/standards"> * ISO/IEC 9899 - Programming languages - C</a> */ public class CReferenceTest { - private static final double inf = Double.POSITIVE_INFINITY; + /** + * The maximum units of least precision allowed between values. + * + * <p>In the normal use case this is set to zero and ignored. + * It can be set to a non-zero value and it overrides the ulps values used in + * each test if greater in magnitude. This can be used to output a report + * of the ULPS between Complex and the reference data. + */ + private static final long MAX_ULPS = 0; /** * Assert the two numbers are equal within the provided units of least precision. @@ -49,14 +59,16 @@ public class CReferenceTest { final long e = Double.doubleToLongBits(expected); final long a = Double.doubleToLongBits(actual); final long delta = Math.abs(e - a); - if (delta > maxUlps) { + if (delta > Math.abs(maxUlps)) { // DEBUG: if (maxUlps < 0) { // CHECKSTYLE: stop Regex - System.out.printf("%s: %s != %s (ulps=%d)%n", msg.get(), expected, actual, delta); + System.out.printf("%s: expected <%s> != actual <%s> (ulps=%d)%n", + msg.get(), expected, actual, delta); // CHECKSTYLE: resume Regex } else { - Assertions.fail(String.format("%s: %s != %s (ulps=%d)", msg.get(), expected, actual, delta)); + Assertions.fail(String.format("%s: expected <%s> != actual <%s> (ulps=%d)", + msg.get(), expected, actual, delta)); } } } @@ -64,434 +76,156 @@ public class CReferenceTest { /** * Assert the operation on the complex number is equal to the expected value. * - * <p>The results are are considered equal if there are no floating-point values between them. + * <p>The results are considered equal within the provided units of least + * precision. The maximum count of numbers allowed between the two values is + * {@code maxUlps - 1}. * - * @param a Real part. - * @param b Imaginary part. + * @param c Input number. * @param operation the operation - * @param x Expected real part. - * @param y Expected imaginary part. + * @param expected Expected result. + * @param maxUlps the maximum units of least precision between the two values */ - private static void assertComplex(double a, double b, + private static void assertComplex(Complex c, UnaryOperator<Complex> operation, - double x, double y) { - assertComplex(a, b, operation, x, y, 1); + Complex expected, long maxUlps) { + final Complex z = operation.apply(c); + assertEquals(() -> c + ": real", expected.real(), z.real(), maxUlps); + assertEquals(() -> c + ": imaginary", expected.imag(), z.imag(), maxUlps); } /** - * Assert the operation on the complex number is equal to the expected value. + * Assert the operation on the complex numbers is equal to the expected value. * * <p>The results are considered equal within the provided units of least * precision. The maximum count of numbers allowed between the two values is * {@code maxUlps - 1}. * - * @param a Real part. - * @param b Imaginary part. + * @param c1 First number. + * @param c2 Second number. * @param operation the operation - * @param x Expected real part. - * @param y Expected imaginary part. + * @param expected Expected real part. * @param maxUlps the maximum units of least precision between the two values */ - private static void assertComplex(double a, double b, - UnaryOperator<Complex> operation, - double x, double y, long maxUlps) { - final Complex c = Complex.ofCartesian(a, b); - final Complex z = operation.apply(c); - assertEquals(() -> c + ": real", x, z.getReal(), maxUlps); - assertEquals(() -> c + ": imaginary", y, z.getImaginary(), maxUlps); + private static void assertComplex(Complex c1, Complex c2, + BiFunction<Complex, Complex, Complex> operation, + Complex expected, long maxUlps) { + final Complex z = operation.apply(c1, c2); + assertEquals(() -> c1 + " op " + c2 + ": real", expected.real(), z.real(), maxUlps); + assertEquals(() -> c1 + " op " + c2 + ": imaginary", expected.imag(), z.imag(), maxUlps); } /** - * Assert the operation on the complex numbers is equal to the expected value. + * Assert the operation using the data loaded from test resources. * - * <p>The results are considered equal if there are no floating-point values between them. - * - * @param a Real part of first number. - * @param b Imaginary part of first number. - * @param c Real part of second number. - * @param d Imaginary part of second number. + * @param testData Test data resource name. * @param operation the operation - * @param x Expected real part. - * @param y Expected imaginary part. + * @param maxUlps the maximum units of least precision between the two values */ - private static void assertComplex(double a, double b, double c, double d, - BiFunction<Complex, Complex, Complex> operation, - double x, double y) { - assertComplex(a, b, c, d, operation, x, y, 1); + private static void assertOperation(String testData, + UnaryOperator<Complex> operation, long maxUlps) { + final List<Complex[]> data = TestUtils.loadTestData(testData); + final long ulps = getTestUlps(maxUlps); + for (final Complex[] pair : data) { + assertComplex(pair[0], operation, pair[1], ulps); + } } /** - * Assert the operation on the complex numbers is equal to the expected value. + * Assert the operation using the data loaded from test resources. * - * <p>The results are considered equal within the provided units of least - * precision. The maximum count of numbers allowed between the two values is - * {@code maxUlps - 1}. - * - * @param a Real part of first number. - * @param b Imaginary part of first number. - * @param c Real part of second number. - * @param d Imaginary part of second number. + * @param testData Test data resource name. * @param operation the operation - * @param x Expected real part. - * @param y Expected imaginary part. * @param maxUlps the maximum units of least precision between the two values */ - // CHECKSTYLE: stop ParameterNumberCheck - private static void assertComplex(double a, double b, double c, double d, - BiFunction<Complex, Complex, Complex> operation, - double x, double y, long maxUlps) { - final Complex c1 = Complex.ofCartesian(a, b); - final Complex c2 = Complex.ofCartesian(c, d); - final Complex z = operation.apply(c1, c2); - assertEquals(() -> c1 + " op " + c2 + ": real", x, z.getReal(), maxUlps); - assertEquals(() -> c1 + " op " + c2 + ": imaginary", y, z.getImaginary(), maxUlps); + private static void assertBiOperation(String testData, + BiFunction<Complex, Complex, Complex> operation, long maxUlps) { + final List<Complex[]> data = TestUtils.loadTestData(testData); + final long ulps = getTestUlps(maxUlps); + for (final Complex[] triple : data) { + assertComplex(triple[0], triple[1], operation, triple[2], ulps); + } + } + + /** + * Gets the test ulps. This uses the input value of the global setting if that is greater + * in magnitude. + * + * @param ulps the ulps + * @return the test ulps + */ + private static long getTestUlps(long ulps) { + final long max = Math.max(Math.abs(ulps), Math.abs(MAX_ULPS)); + // If either are negative then choose negative for debugging output + return (ulps | MAX_ULPS) < 0 ? -max : max; } @Test public void testAcos() { - assertComplex(-2, 0.0, Complex::acos, 3.1415926535897931, -1.3169578969248164); - assertComplex(-2, 0.5, Complex::acos, 2.8638383970320791, -1.3618009008578467, 3); - assertComplex(-2, 1, Complex::acos, 2.6342363503726487, -1.4693517443681854); - assertComplex(-2, 2, Complex::acos, 2.3250454714929427, -1.7343245214879679); - assertComplex(-1, 0.0, Complex::acos, 3.1415926535897931, -0.0); - assertComplex(-1, 0.5, Complex::acos, 2.4667038080037869, -0.73285767597364526); - assertComplex(-1, 1, Complex::acos, 2.2370357592874122, -1.0612750619050364, 4); - assertComplex(-1, 2, Complex::acos, 1.997874913187373, -1.5285709194809995, 9); - assertComplex(-0.5, 0.0, Complex::acos, 2.0943951023931953, -1.1102230246251565e-16); - assertComplex(-0.5, 0.5, Complex::acos, 2.023074773946087, -0.53063753095251776); - assertComplex(-0.5, 1, Complex::acos, 1.9202353896521094, -0.92613303135018232, 2); - assertComplex(-0.5, 2, Complex::acos, 1.7918149624177808, -1.4657153519472903, 2); - assertComplex(-0.0, 0.0, Complex::acos, 1.5707963267948966, -0.0); - assertComplex(-0.0, 0.5, Complex::acos, 1.5707963267948966, -0.48121182505960336); - assertComplex(-0.0, 1, Complex::acos, 1.5707963267948963, -0.88137358701954283); - assertComplex(-0.0, 2, Complex::acos, 1.5707963267948959, -1.4436354751788099, 3); - assertComplex(0.0, 0.0, Complex::acos, 1.5707963267948966, -0.0); - assertComplex(0.0, 0.5, Complex::acos, 1.5707963267948966, -0.48121182505960347, 2); - assertComplex(0.0, 1, Complex::acos, 1.5707963267948966, -0.88137358701954294); - assertComplex(0.0, 2, Complex::acos, 1.5707963267948966, -1.4436354751788103, 2); - assertComplex(0.5, 0.0, Complex::acos, 1.0471975511965976, -1.1102230246251565e-16); - assertComplex(0.5, 0.5, Complex::acos, 1.1185178796437059, -0.53063753095251787); - assertComplex(0.5, 1, Complex::acos, 1.2213572639376833, -0.92613303135018255, 2); - assertComplex(0.5, 2, Complex::acos, 1.3497776911720127, -1.4657153519472905); - assertComplex(1, 0.0, Complex::acos, 0.0, -0.0); - assertComplex(1, 0.5, Complex::acos, 0.67488884558600637, -0.73285767597364526); - assertComplex(1, 1, Complex::acos, 0.90455689430238129, -1.0612750619050355); - assertComplex(1, 2, Complex::acos, 1.1437177404024204, -1.528570919480998, 2); - assertComplex(2, 0.0, Complex::acos, 0.0, -1.3169578969248166); - assertComplex(2, 0.5, Complex::acos, 0.27775425655771396, -1.3618009008578458); - assertComplex(2, 1, Complex::acos, 0.50735630321714453, -1.4693517443681852); - assertComplex(2, 2, Complex::acos, 0.8165471820968504, -1.7343245214879663, 7); + assertOperation("data/acos.txt", Complex::acos, 36); } @Test public void testAcosh() { - assertComplex(-2, 0.0, Complex::acosh, 1.3169578969248164, 3.1415926535897931); - assertComplex(-2, 0.5, Complex::acosh, 1.3618009008578467, 2.8638383970320791, 3); - assertComplex(-2, 1, Complex::acosh, 1.4693517443681854, 2.6342363503726487); - assertComplex(-2, 2, Complex::acosh, 1.7343245214879679, 2.3250454714929427); - assertComplex(-1, 0.0, Complex::acosh, 0.0, 3.1415926535897931); - assertComplex(-1, 0.5, Complex::acosh, 0.73285767597364526, 2.4667038080037869); - assertComplex(-1, 1, Complex::acosh, 1.0612750619050364, 2.2370357592874122, 4); - assertComplex(-1, 2, Complex::acosh, 1.5285709194809995, 1.997874913187373, 9); - assertComplex(-0.5, 0.0, Complex::acosh, 1.1102230246251565e-16, 2.0943951023931953); - assertComplex(-0.5, 0.5, Complex::acosh, 0.53063753095251776, 2.023074773946087); - assertComplex(-0.5, 1, Complex::acosh, 0.92613303135018232, 1.9202353896521094, 2); - assertComplex(-0.5, 2, Complex::acosh, 1.4657153519472903, 1.7918149624177808, 2); - assertComplex(-0.0, 0.0, Complex::acosh, 0.0, 1.5707963267948966); - assertComplex(-0.0, 0.5, Complex::acosh, 0.48121182505960336, 1.5707963267948966); - assertComplex(-0.0, 1, Complex::acosh, 0.88137358701954283, 1.5707963267948963); - assertComplex(-0.0, 2, Complex::acosh, 1.4436354751788099, 1.5707963267948959, 3); - assertComplex(0.0, 0.0, Complex::acosh, 0.0, 1.5707963267948966); - assertComplex(0.0, 0.5, Complex::acosh, 0.48121182505960347, 1.5707963267948966, 2); - assertComplex(0.0, 1, Complex::acosh, 0.88137358701954294, 1.5707963267948966); - assertComplex(0.0, 2, Complex::acosh, 1.4436354751788103, 1.5707963267948966, 2); - assertComplex(0.5, 0.0, Complex::acosh, 1.1102230246251565e-16, 1.0471975511965976); - assertComplex(0.5, 0.5, Complex::acosh, 0.53063753095251787, 1.1185178796437059); - assertComplex(0.5, 1, Complex::acosh, 0.92613303135018255, 1.2213572639376833, 2); - assertComplex(0.5, 2, Complex::acosh, 1.4657153519472905, 1.3497776911720127); - assertComplex(1, 0.0, Complex::acosh, 0.0, 0.0); - assertComplex(1, 0.5, Complex::acosh, 0.73285767597364526, 0.67488884558600637); - assertComplex(1, 1, Complex::acosh, 1.0612750619050355, 0.90455689430238129); - assertComplex(1, 2, Complex::acosh, 1.528570919480998, 1.1437177404024204, 2); - assertComplex(2, 0.0, Complex::acosh, 1.3169578969248166, 0.0); - assertComplex(2, 0.5, Complex::acosh, 1.3618009008578458, 0.27775425655771396); - assertComplex(2, 1, Complex::acosh, 1.4693517443681852, 0.50735630321714453, 7); - assertComplex(2, 2, Complex::acosh, 1.7343245214879663, 0.8165471820968504, 7); + assertOperation("data/acosh.txt", Complex::acosh, 36); } @Test public void testAsinh() { // Odd function: negative real cases defined by positive real cases - assertComplex(0.0, 0.0, Complex::asinh, 0.0, 0.0); - assertComplex(0.0, 0.5, Complex::asinh, 1.1102230246251565e-16, 0.52359877559829893); - assertComplex(0.0, 1, Complex::asinh, 0.0, 1.5707963267948966); - assertComplex(0.0, 2, Complex::asinh, 1.3169578969248166, 1.5707963267948966); - assertComplex(0.5, 0.0, Complex::asinh, 0.48121182505960347, 0.0); - assertComplex(0.5, 0.5, Complex::asinh, 0.53063753095251787, 0.45227844715119064); - assertComplex(0.5, 1, Complex::asinh, 0.73285767597364526, 0.8959074812088903); - assertComplex(0.5, 2, Complex::asinh, 1.3618009008578458, 1.2930420702371828); - assertComplex(1, 0.0, Complex::asinh, 0.88137358701954294, 0.0); - assertComplex(1, 0.5, Complex::asinh, 0.92613303135018255, 0.34943906285721327); - assertComplex(1, 1, Complex::asinh, 1.0612750619050357, 0.66623943249251527); - assertComplex(1, 2, Complex::asinh, 1.4693517443681852, 1.0634400235777519); - assertComplex(2, 0.0, Complex::asinh, 1.4436354751788103, 0.0); - assertComplex(2, 0.5, Complex::asinh, 1.4657153519472905, 0.22101863562288387); - assertComplex(2, 1, Complex::asinh, 1.528570919480998, 0.42707858639247614); - assertComplex(2, 2, Complex::asinh, 1.7343245214879663, 0.75424914469804605); + assertOperation("data/asinh.txt", Complex::asinh, 2); } @Test public void testAtanh() { // Odd function: negative real cases defined by positive real cases - assertComplex(0.0, 0.0, Complex::atanh, 0.0, 0.0); - assertComplex(0.0, 0.5, Complex::atanh, 0.0, 0.46364760900080615); - assertComplex(0.0, 1, Complex::atanh, 0.0, 0.78539816339744828); - assertComplex(0.0, 2, Complex::atanh, 0.0, 1.1071487177940904); - assertComplex(0.5, 0.0, Complex::atanh, 0.54930614433405489, 0.0); - assertComplex(0.5, 0.5, Complex::atanh, 0.40235947810852513, 0.5535743588970452); - assertComplex(0.5, 1, Complex::atanh, 0.23887786125685911, 0.84757566067082901); - assertComplex(0.5, 2, Complex::atanh, 0.096415620202996211, 1.1265564408348223, 7); - assertComplex(1, 0.0, Complex::atanh, inf, 0.0); - assertComplex(1, 0.5, Complex::atanh, 0.70830333601405404, 0.90788749496088039); - assertComplex(1, 1, Complex::atanh, 0.40235947810852513, 1.0172219678978514); - assertComplex(1, 2, Complex::atanh, 0.17328679513998635, 1.1780972450961724); - assertComplex(2, 0.0, Complex::atanh, 0.54930614433405489, 1.5707963267948966); - assertComplex(2, 0.5, Complex::atanh, 0.50037000005253096, 1.4215468610018069); - assertComplex(2, 1, Complex::atanh, 0.40235947810852513, 1.3389725222944935); - assertComplex(2, 2, Complex::atanh, 0.23887786125685906, 1.311223269671635); + assertOperation("data/atanh.txt", Complex::atanh, 26); } @Test public void testCosh() { // Even function: negative real cases defined by positive real cases - assertComplex(0.0, 0.0, Complex::cosh, 1, 0.0); - assertComplex(0.0, 0.5, Complex::cosh, 0.87758256189037276, 0.0); - assertComplex(0.0, 1, Complex::cosh, 0.54030230586813977, 0.0); - assertComplex(0.0, 2, Complex::cosh, -0.41614683654714241, 0.0); - assertComplex(0.5, 0.0, Complex::cosh, 1.1276259652063807, 0.0); - assertComplex(0.5, 0.5, Complex::cosh, 0.9895848833999199, 0.24982639750046154); - assertComplex(0.5, 1, Complex::cosh, 0.60925890915779424, 0.43848657989259532); - assertComplex(0.5, 2, Complex::cosh, -0.46925797822905341, 0.473830620416407); - assertComplex(1, 0.0, Complex::cosh, 1.5430806348152437, 0.0); - assertComplex(1, 0.5, Complex::cosh, 1.3541806567045842, 0.5634214652309818); - assertComplex(1, 1, Complex::cosh, 0.83373002513114913, 0.98889770576286506); - assertComplex(1, 2, Complex::cosh, -0.64214812471551996, 1.0686074213827783); - assertComplex(2, 0.0, Complex::cosh, 3.7621956910836314, 0.0); - assertComplex(2, 0.5, Complex::cosh, 3.3016373329140944, 1.7388095044743164); - assertComplex(2, 1, Complex::cosh, 2.0327230070196656, 3.0518977991517997); - assertComplex(2, 2, Complex::cosh, -1.5656258353157435, 3.2978948363112366); + assertOperation("data/cosh.txt", Complex::cosh, 2); } @Test public void testSinh() { // Odd function: negative real cases defined by positive real cases - assertComplex(0.0, 0.0, Complex::sinh, 0.0, 0.0); - assertComplex(0.0, 0.5, Complex::sinh, 0.0, 0.47942553860420301); - assertComplex(0.0, 1, Complex::sinh, 0.0, 0.8414709848078965); - assertComplex(0.0, 2, Complex::sinh, -0.0, 0.90929742682568171); - assertComplex(0.5, 0.0, Complex::sinh, 0.52109530549374738, 0.0); - assertComplex(0.5, 0.5, Complex::sinh, 0.45730415318424927, 0.54061268571315335); - assertComplex(0.5, 1, Complex::sinh, 0.28154899513533443, 0.94886453143716798); - assertComplex(0.5, 2, Complex::sinh, -0.21685216292078974, 1.0253473885839877); - assertComplex(1, 0.0, Complex::sinh, 1.1752011936438014, 0.0); - assertComplex(1, 0.5, Complex::sinh, 1.0313360742545512, 0.73979226445601376); - assertComplex(1, 1, Complex::sinh, 0.63496391478473613, 1.2984575814159773); - assertComplex(1, 2, Complex::sinh, -0.48905625904129368, 1.4031192506220405); - assertComplex(2, 0.0, Complex::sinh, 3.6268604078470186, 0.0); - assertComplex(2, 0.5, Complex::sinh, 3.1828694483371489, 1.8036926955321817); - assertComplex(2, 1, Complex::sinh, 1.9596010414216061, 3.1657785132161682); - assertComplex(2, 2, Complex::sinh, -1.5093064853236156, 3.4209548611170133); + assertOperation("data/sinh.txt", Complex::sinh, 2); } @Test public void testTanh() { // Odd function: negative real cases defined by positive real cases - assertComplex(0.0, 0.0, Complex::tanh, 0.0, 0.0); - assertComplex(0.0, 0.5, Complex::tanh, 0.0, 0.54630248984379048); - assertComplex(0.0, 1, Complex::tanh, 0.0, 1.5574077246549021); - assertComplex(0.0, 2, Complex::tanh, 0.0, -2.1850398632615189); - assertComplex(0.5, 0.0, Complex::tanh, 0.46211715726000974, 0.0); - assertComplex(0.5, 0.5, Complex::tanh, 0.56408314126749848, 0.40389645531602575, 2); - assertComplex(0.5, 1, Complex::tanh, 1.042830728344361, 0.80687741216308495); - assertComplex(0.5, 2, Complex::tanh, 1.3212865837711918, -0.85087812114493777, 2); - assertComplex(1, 0.0, Complex::tanh, 0.76159415595576485, 0.0); - assertComplex(1, 0.5, Complex::tanh, 0.84296620484578311, 0.19557731006593398); - assertComplex(1, 1, Complex::tanh, 1.0839233273386946, 0.27175258531951174); - assertComplex(1, 2, Complex::tanh, 1.1667362572409199, -0.24345820118572523); - assertComplex(2, 0.0, Complex::tanh, 0.9640275800758169, 0.0); - assertComplex(2, 0.5, Complex::tanh, 0.97994084996173814, 0.030215987322877575); - assertComplex(2, 1, Complex::tanh, 1.0147936161466335, 0.033812826079896691); - assertComplex(2, 2, Complex::tanh, 1.0238355945704727, -0.028392952868232287); + assertOperation("data/tanh.txt", Complex::tanh, 34); } @Test public void testExp() { - assertComplex(-2, 0.0, Complex::exp, 0.1353352832366127, 0.0); - assertComplex(-2, 0.5, Complex::exp, 0.11876788457694579, 0.064883191057865414); - assertComplex(-2, 1, Complex::exp, 0.073121965598059641, 0.1138807140643681); - assertComplex(-2, 2, Complex::exp, -0.056319349992127891, 0.12306002480577674); - assertComplex(-1, 0.0, Complex::exp, 0.36787944117144233, 0.0); - assertComplex(-1, 0.5, Complex::exp, 0.32284458245003306, 0.17637079922503196); - assertComplex(-1, 1, Complex::exp, 0.19876611034641298, 0.30955987565311222); - assertComplex(-1, 2, Complex::exp, -0.15309186567422631, 0.33451182923926226); - assertComplex(-0.5, 0.0, Complex::exp, 0.60653065971263342, 0.0); - assertComplex(-0.5, 0.5, Complex::exp, 0.53228073021567079, 0.29078628821269187); - assertComplex(-0.5, 1, Complex::exp, 0.32770991402245986, 0.51037795154457277); - assertComplex(-0.5, 2, Complex::exp, -0.25240581530826373, 0.55151676816758077); - assertComplex(-0.0, 0.0, Complex::exp, 1, 0.0); - assertComplex(-0.0, 0.5, Complex::exp, 0.87758256189037276, 0.47942553860420301); - assertComplex(-0.0, 1, Complex::exp, 0.54030230586813977, 0.8414709848078965); - assertComplex(-0.0, 2, Complex::exp, -0.41614683654714241, 0.90929742682568171); - assertComplex(0.0, 0.0, Complex::exp, 1, 0.0); - assertComplex(0.0, 0.5, Complex::exp, 0.87758256189037276, 0.47942553860420301); - assertComplex(0.0, 1, Complex::exp, 0.54030230586813977, 0.8414709848078965); - assertComplex(0.0, 2, Complex::exp, -0.41614683654714241, 0.90929742682568171); - assertComplex(0.5, 0.0, Complex::exp, 1.6487212707001282, 0.0); - assertComplex(0.5, 0.5, Complex::exp, 1.4468890365841693, 0.79043908321361489); - assertComplex(0.5, 1, Complex::exp, 0.89080790429312873, 1.3873511113297634); - assertComplex(0.5, 2, Complex::exp, -0.68611014114984314, 1.4991780090003948); - assertComplex(1, 0.0, Complex::exp, 2.7182818284590451, 0.0); - assertComplex(1, 0.5, Complex::exp, 2.3855167309591354, 1.3032137296869954); - assertComplex(1, 1, Complex::exp, 1.4686939399158851, 2.2873552871788423); - assertComplex(1, 2, Complex::exp, -1.1312043837568135, 2.4717266720048188); - assertComplex(2, 0.0, Complex::exp, 7.3890560989306504, 0.0); - assertComplex(2, 0.5, Complex::exp, 6.4845067812512438, 3.5425022000064983); - assertComplex(2, 1, Complex::exp, 3.9923240484412719, 6.2176763123679679); - assertComplex(2, 2, Complex::exp, -3.0749323206393591, 6.7188496974282499); + assertOperation("data/exp.txt", Complex::exp, 2); } @Test public void testLog() { - assertComplex(-2, 0.0, Complex::log, 0.69314718055994529, 3.1415926535897931); - assertComplex(-2, 0.5, Complex::log, 0.72345949146816269, 2.8966139904629289); - assertComplex(-2, 1, Complex::log, 0.80471895621705025, 2.677945044588987); - assertComplex(-2, 2, Complex::log, 1.0397207708399181, 2.3561944901923448); - assertComplex(-1, 0.0, Complex::log, 0.0, 3.1415926535897931); - assertComplex(-1, 0.5, Complex::log, 0.11157177565710492, 2.677945044588987); - assertComplex(-1, 1, Complex::log, 0.3465735902799727, 2.3561944901923448); - assertComplex(-1, 2, Complex::log, 0.80471895621705025, 2.0344439357957027); - assertComplex(-0.5, 0.0, Complex::log, -0.69314718055994529, 3.1415926535897931); - assertComplex(-0.5, 0.5, Complex::log, -0.34657359027997259, 2.3561944901923448); - assertComplex(-0.5, 1, Complex::log, 0.11157177565710492, 2.0344439357957027); - assertComplex(-0.5, 2, Complex::log, 0.72345949146816269, 1.8157749899217608); - assertComplex(-0.0, 0.0, Complex::log, -inf, 3.1415926535897931); - assertComplex(-0.0, 0.5, Complex::log, -0.69314718055994529, 1.5707963267948966); - assertComplex(-0.0, 1, Complex::log, 0.0, 1.5707963267948966); - assertComplex(-0.0, 2, Complex::log, 0.69314718055994529, 1.5707963267948966); - assertComplex(0.0, 0.0, Complex::log, -inf, 0.0); - assertComplex(0.0, 0.5, Complex::log, -0.69314718055994529, 1.5707963267948966); - assertComplex(0.0, 1, Complex::log, 0.0, 1.5707963267948966); - assertComplex(0.0, 2, Complex::log, 0.69314718055994529, 1.5707963267948966); - assertComplex(0.5, 0.0, Complex::log, -0.69314718055994529, 0.0); - assertComplex(0.5, 0.5, Complex::log, -0.34657359027997259, 0.78539816339744828); - assertComplex(0.5, 1, Complex::log, 0.11157177565710492, 1.1071487177940904); - assertComplex(0.5, 2, Complex::log, 0.72345949146816269, 1.3258176636680326); - assertComplex(1, 0.0, Complex::log, 0.0, 0.0); - assertComplex(1, 0.5, Complex::log, 0.11157177565710492, 0.46364760900080609); - assertComplex(1, 1, Complex::log, 0.3465735902799727, 0.78539816339744828); - assertComplex(1, 2, Complex::log, 0.80471895621705025, 1.1071487177940904); - assertComplex(2, 0.0, Complex::log, 0.69314718055994529, 0.0); - assertComplex(2, 0.5, Complex::log, 0.72345949146816269, 0.24497866312686414); - assertComplex(2, 1, Complex::log, 0.80471895621705025, 0.46364760900080609); - assertComplex(2, 2, Complex::log, 1.0397207708399181, 0.78539816339744828); + assertOperation("data/log.txt", Complex::log, 3); } @Test public void testSqrt() { - // Note: When computed in polar coordinates: - // real = (x^2 + y^2)^0.25 * cos(0.5 * atan2(y, x)) - // imag = (x^2 + y^2)^0.25 * sin(0.5 * atan2(y, x)) - // If x is positive and y is +/-0.0 atan2 returns +/-0. - // If x is negative and y is +/-0.0 atan2 returns +/-PI. - // This causes problems as - // cos(0.5 * PI) = 6.123233995736766e-17 - // assert: Math.cos(Math.acos(0)) != 0.0 - // Thus polar computation will produce incorrect output when - // there is no imaginary component and real is negative. - // The computation should be done for real only numbers separately. - - // Check overflow safe. - final double a = Double.MAX_VALUE; - final double b = a / 4; - Assertions.assertEquals(inf, Complex.ofCartesian(a, b).abs(), "Expected overflow"); - // Compute the expected new magnitude by expressing b as a scale factor of a: - // (x^2 + y^2)^0.25 - // = sqrt(sqrt(a^2 + (b/a)^2 * a^2)) - // = sqrt(sqrt((1+(b/a)^2) * a^2)) - // = sqrt(sqrt((1+(b/a)^2))) * sqrt(a) - final double newAbs = Math.sqrt(Math.sqrt(1 + (b / a) * (b / a))) * Math.sqrt(a); - assertComplex(a, b, Complex::sqrt, newAbs * Math.cos(0.5 * Math.atan2(b, a)), - newAbs * Math.sin(0.5 * Math.atan2(b, a)), 3); - assertComplex(b, a, Complex::sqrt, newAbs * Math.cos(0.5 * Math.atan2(a, b)), - newAbs * Math.sin(0.5 * Math.atan2(a, b)), 2); - - assertComplex(-2, 0.0, Complex::sqrt, 0, 1.4142135623730951); - assertComplex(-2, 0.5, Complex::sqrt, 0.17543205637629397, 1.425053124063947, 5); - assertComplex(-2, 1, Complex::sqrt, 0.3435607497225126, 1.4553466902253549, 3); - assertComplex(-2, 2, Complex::sqrt, 0.64359425290558281, 1.5537739740300374, 2); - assertComplex(-1, 0.0, Complex::sqrt, 0, 1); - assertComplex(-1, 0.5, Complex::sqrt, 0.24293413587832291, 1.0290855136357462, 3); - assertComplex(-1, 1, Complex::sqrt, 0.45508986056222739, 1.0986841134678098); - assertComplex(-1, 2, Complex::sqrt, 0.78615137775742339, 1.2720196495140688); - assertComplex(-0.5, 0.0, Complex::sqrt, 0, 0.70710678118654757); - assertComplex(-0.5, 0.5, Complex::sqrt, 0.3217971264527914, 0.77688698701501868, 2); - assertComplex(-0.5, 1, Complex::sqrt, 0.55589297025142126, 0.89945371997393353); - assertComplex(-0.5, 2, Complex::sqrt, 0.88361553087551337, 1.1317139242778693, 2); - assertComplex(-0.0, 0.0, Complex::sqrt, 0.0, 0.0); - assertComplex(-0.0, 0.5, Complex::sqrt, 0.50000000000000011, 0.5); - assertComplex(-0.0, 1, Complex::sqrt, 0.70710678118654757, 0.70710678118654746); - assertComplex(-0.0, 2, Complex::sqrt, 1.0000000000000002, 1); - assertComplex(0.0, 0.0, Complex::sqrt, 0.0, 0.0); - assertComplex(0.0, 0.5, Complex::sqrt, 0.50000000000000011, 0.5); - assertComplex(0.0, 1, Complex::sqrt, 0.70710678118654757, 0.70710678118654746); - assertComplex(0.0, 2, Complex::sqrt, 1.0000000000000002, 1); - assertComplex(0.5, 0.0, Complex::sqrt, 0.70710678118654757, 0.0); - assertComplex(0.5, 0.5, Complex::sqrt, 0.77688698701501868, 0.32179712645279135); - assertComplex(0.5, 1, Complex::sqrt, 0.89945371997393364, 0.55589297025142115); - assertComplex(0.5, 2, Complex::sqrt, 1.1317139242778693, 0.88361553087551337); - assertComplex(1, 0.0, Complex::sqrt, 1, 0.0); - assertComplex(1, 0.5, Complex::sqrt, 1.0290855136357462, 0.24293413587832283); - assertComplex(1, 1, Complex::sqrt, 1.0986841134678098, 0.45508986056222733); - assertComplex(1, 2, Complex::sqrt, 1.272019649514069, 0.78615137775742328); - assertComplex(2, 0.0, Complex::sqrt, 1.4142135623730951, 0.0); - assertComplex(2, 0.5, Complex::sqrt, 1.425053124063947, 0.17543205637629383); - assertComplex(2, 1, Complex::sqrt, 1.4553466902253549, 0.34356074972251244); - assertComplex(2, 2, Complex::sqrt, 1.5537739740300374, 0.6435942529055827); + assertOperation("data/sqrt.txt", Complex::sqrt, 1); } @Test public void testMultiply() { - assertComplex(2, 3, 5, 4, Complex::multiply, -2, 23); - assertComplex(5, 4, 2, 3, Complex::multiply, -2, 23); - assertComplex(2, 3, -5, 4, Complex::multiply, -22, -7); - assertComplex(-5, 4, 2, 3, Complex::multiply, -22, -7); - assertComplex(2, 3, 5, -4, Complex::multiply, 22, 7); - assertComplex(5, -4, 2, 3, Complex::multiply, 22, 7); - assertComplex(2, 3, -5, -4, Complex::multiply, 2, -23); - assertComplex(-5, -4, 2, 3, Complex::multiply, 2, -23); + assertBiOperation("data/multiply.txt", Complex::multiply, 0); } @Test public void testDivide() { - assertComplex(2, 3, 5, 4, Complex::divide, 0.53658536585365857, 0.17073170731707318); - assertComplex(5, 4, 2, 3, Complex::divide, 1.6923076923076923, -0.53846153846153844); - assertComplex(2, 3, -5, 4, Complex::divide, 0.04878048780487805, -0.56097560975609762); - assertComplex(-5, 4, 2, 3, Complex::divide, 0.15384615384615385, 1.7692307692307692); - assertComplex(2, 3, 5, -4, Complex::divide, -0.04878048780487805, 0.56097560975609762); - assertComplex(5, -4, 2, 3, Complex::divide, -0.15384615384615385, -1.7692307692307692); - assertComplex(2, 3, -5, -4, Complex::divide, -0.53658536585365857, -0.17073170731707318); - assertComplex(-5, -4, 2, 3, Complex::divide, -1.6923076923076923, 0.53846153846153844); + assertBiOperation("data/divide.txt", Complex::divide, 0); } @Test public void testPowComplex() { - assertComplex(2, 3, 5, 4, Complex::pow, -9.7367145095888414, -6.9377513609299886, 2); - assertComplex(5, 4, 2, 3, Complex::pow, 4.354910316631539, 3.2198331430252156, 8); - assertComplex(2, 3, -5, 4, Complex::pow, 3.1452105198427317e-05, 6.8990150088148226e-06); - assertComplex(-5, 4, 2, 3, Complex::pow, -0.011821399482548253, -0.022082334539521097); - assertComplex(2, 3, 5, -4, Complex::pow, 30334.832969842264, -6653.9414970320349); - assertComplex(5, -4, 2, 3, Complex::pow, -146.48661898442663, -273.63651239033993, 9); - assertComplex(2, 3, -5, -4, Complex::pow, -0.068119398044204305, 0.048537465694561743, 2); - assertComplex(-5, -4, 2, 3, Complex::pow, 53964.514878760994, 39899.038308625939); + assertBiOperation("data/pow.txt", Complex::pow, 17); } } diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/TestUtils.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/TestUtils.java index 17d7ac8..c1cc4a6 100644 --- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/TestUtils.java +++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/TestUtils.java @@ -17,19 +17,22 @@ package org.apache.commons.numbers.complex; +import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStreamReader; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.util.ArrayList; +import java.util.List; import org.apache.commons.numbers.core.Precision; import org.junit.jupiter.api.Assertions; /** - * Test utilities. - * TODO: Cleanup (remove unused and obsolete methods). + * Test utilities. TODO: Cleanup (remove unused and obsolete methods). */ public final class TestUtils { /** @@ -40,9 +43,9 @@ public final class TestUtils { } /** - * Verifies that real and imaginary parts of the two complex arguments are exactly the - * same as defined by {@link Double#compare(double, double)}. Also ensures that NaN / - * infinite components match. + * Verifies that real and imaginary parts of the two complex arguments are + * exactly the same as defined by {@link Double#compare(double, double)}. Also + * ensures that NaN / infinite components match. * * @param expected the expected value * @param actual the actual value @@ -53,8 +56,8 @@ public final class TestUtils { } /** - * Verifies that real and imaginary parts of the two complex arguments differ by at - * most delta. Also ensures that NaN / infinite components match. + * Verifies that real and imaginary parts of the two complex arguments differ by + * at most delta. Also ensures that NaN / infinite components match. * * @param expected the expected value * @param actual the actual value @@ -66,11 +69,11 @@ public final class TestUtils { } /** - * Serializes an object to a bytes array and then recovers the object from the bytes array. - * Returns the deserialized object. + * Serializes an object to a bytes array and then recovers the object from the + * bytes array. Returns the deserialized object. * - * @param o object to serialize and recover - * @return the recovered, deserialized object + * @param o object to serialize and recover + * @return the recovered, deserialized object */ public static Object serializeAndRecover(Object o) { try { @@ -91,10 +94,10 @@ public final class TestUtils { } /** - * Verifies that serialization preserves equals and hashCode. - * Serializes the object, then recovers it and checks equals and hash code. + * Verifies that serialization preserves equals and hashCode. Serializes the + * object, then recovers it and checks equals and hash code. * - * @param object the object to serialize and recover + * @param object the object to serialize and recover */ public static void checkSerializedEquality(Object object) { final Object object2 = serializeAndRecover(object); @@ -103,31 +106,29 @@ public final class TestUtils { } /** - * Verifies that the relative error in actual vs. expected is less than or - * equal to relativeError. If expected is infinite or NaN, actual must be - * the same (NaN or infinity of the same sign). + * Verifies that the relative error in actual vs. expected is less than or equal + * to relativeError. If expected is infinite or NaN, actual must be the same + * (NaN or infinity of the same sign). * * @param expected expected value - * @param actual observed value - * @param relativeError maximum allowable relative error + * @param actual observed value + * @param relativeError maximum allowable relative error */ - public static void assertRelativelyEquals(double expected, double actual, - double relativeError) { + public static void assertRelativelyEquals(double expected, double actual, double relativeError) { assertRelativelyEquals(null, expected, actual, relativeError); } /** - * Verifies that the relative error in actual vs. expected is less than or - * equal to relativeError. If expected is infinite or NaN, actual must be - * the same (NaN or infinity of the same sign). + * Verifies that the relative error in actual vs. expected is less than or equal + * to relativeError. If expected is infinite or NaN, actual must be the same + * (NaN or infinity of the same sign). * - * @param msg message to return with failure + * @param msg message to return with failure * @param expected expected value - * @param actual observed value - * @param relativeError maximum allowable relative error + * @param actual observed value + * @param relativeError maximum allowable relative error */ - public static void assertRelativelyEquals(String msg, double expected, - double actual, double relativeError) { + public static void assertRelativelyEquals(String msg, double expected, double actual, double relativeError) { if (Double.isNaN(expected)) { Assertions.assertTrue(Double.isNaN(actual), msg); } else if (Double.isNaN(actual)) { @@ -145,16 +146,15 @@ public final class TestUtils { /** * Fails iff values does not contain a number within epsilon of z. * - * @param msg message to return with failure + * @param msg message to return with failure * @param values complex array to search - * @param z value sought - * @param epsilon tolerance + * @param z value sought + * @param epsilon tolerance */ - public static void assertContains(String msg, Complex[] values, - Complex z, double epsilon) { + public static void assertContains(String msg, Complex[] values, Complex z, double epsilon) { for (final Complex value : values) { if (Precision.equals(value.getReal(), z.getReal(), epsilon) && - Precision.equals(value.getImaginary(), z.getImaginary(), epsilon)) { + Precision.equals(value.getImaginary(), z.getImaginary(), epsilon)) { return; } } @@ -165,24 +165,22 @@ public final class TestUtils { * Fails iff values does not contain a number within epsilon of z. * * @param values complex array to search - * @param z value sought - * @param epsilon tolerance + * @param z value sought + * @param epsilon tolerance */ - public static void assertContains(Complex[] values, - Complex z, double epsilon) { + public static void assertContains(Complex[] values, Complex z, double epsilon) { assertContains(null, values, z, epsilon); } /** * Fails iff values does not contain a number within epsilon of x. * - * @param msg message to return with failure + * @param msg message to return with failure * @param values double array to search * @param x value sought - * @param epsilon tolerance + * @param epsilon tolerance */ - public static void assertContains(String msg, double[] values, - double x, double epsilon) { + public static void assertContains(String msg, double[] values, double x, double epsilon) { for (final double value : values) { if (Precision.equals(value, x, epsilon)) { return; @@ -196,10 +194,9 @@ public final class TestUtils { * * @param values double array to search * @param x value sought - * @param epsilon tolerance + * @param epsilon tolerance */ - public static void assertContains(double[] values, double x, - double epsilon) { + public static void assertContains(double[] values, double x, double epsilon) { assertContains(null, values, x, epsilon); } @@ -243,8 +240,8 @@ public final class TestUtils { } /** - * Updates observed counts of values in quartiles. - * counts[0] <-> 1st quartile ... counts[3] <-> top quartile + * Updates observed counts of values in quartiles. counts[0] <-> 1st quartile + * ... counts[3] <-> top quartile */ public static void updateCounts(double value, long[] counts, double[] quartiles) { if (value < quartiles[0]) { @@ -259,10 +256,10 @@ public final class TestUtils { } /** - * Eliminates points with zero mass from densityPoints and densityValues parallel - * arrays. Returns the number of positive mass points and collapses the arrays so - * that the first <returned value> elements of the input arrays represent the positive - * mass points. + * Eliminates points with zero mass from densityPoints and densityValues + * parallel arrays. Returns the number of positive mass points and collapses the + * arrays so that the first <returned value> elements of the input arrays + * represent the positive mass points. */ public static int eliminateZeroMassPoints(int[] densityPoints, double[] densityValues) { int positiveMassCount = 0; @@ -287,6 +284,63 @@ public final class TestUtils { } return positiveMassCount; } -} - + /** + * Load test data from resources. + * + * <p>This method can be used to load input complex numbers and the expected + * result after applying a function. + * + * <p>Data is assumed to be a resource available to the class loader. The data + * should be space delimited doubles. Each pair of doubles on a line is + * converted to a Complex. For example the following represents the numbers (0.5 + * - 0 i) and (1.5 + 2 i): + * + * <pre> + * 0.5 -0.0 1.5 2 + * </pre> + * + * <p>An unmatched double not part of a pair on a line will raise an + * AssertionError. + * + * <p>Lines starting with the {@code #} character are ignored. + * + * <p>Lines starting with the {@code ;} character are ignored but printed. This can be used + * to disable tests in the data file. + * + * @param name the resource name + * @return the list + */ + public static List<Complex[]> loadTestData(String name) { + final List<Complex[]> data = new ArrayList<>(); + try (BufferedReader input = new BufferedReader( + new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(name)))) { + for (String line = input.readLine(); line != null; line = input.readLine()) { + // Skip comments and empty lines + if (line.length() == 0 || line.charAt(0) == '#') { + continue; + } + if (line.charAt(0) == ';') { + // CHECKSTYLE: stop all + System.out.println(line); + // CHECKSTYLE: resume + continue; + } + final String[] parts = line.split(" "); + if ((parts.length & 0x1) == 1) { + Assertions.fail("Odd count of numbers on the line: " + line); + } + final Complex[] numbers = new Complex[parts.length / 2]; + for (int i = 0; i < parts.length; i += 2) { + final double a = Double.parseDouble(parts[i]); + final double b = Double.parseDouble(parts[i + 1]); + numbers[i / 2] = Complex.ofCartesian(a, b); + } + data.add(numbers); + } + } catch (NumberFormatException | IOException e) { + Assertions.fail("Failed to load test data: " + name, e); + } + return data; + } +} diff --git a/commons-numbers-complex/src/test/resources/data/acos.txt b/commons-numbers-complex/src/test/resources/data/acos.txt new file mode 100644 index 0000000..f49536a --- /dev/null +++ b/commons-numbers-complex/src/test/resources/data/acos.txt @@ -0,0 +1,243 @@ +# (a + b i) acos(a + b i) +0.0 0.0 1.5707963267948966 -0.0 +0.0 0.5 1.5707963267948966 -0.48121182505960342 +0.0 1 1.5707963267948966 -0.88137358701954305 +0.0 1.5 1.5707963267948966 -1.1947632172871094 +0.0 2 1.5707963267948966 -1.4436354751788103 +0.0 2.5 1.5707963267948966 -1.6472311463710958 +0.0 3 1.5707963267948966 -1.8184464592320668 +0.0 3.5 1.5707963267948966 -1.9657204716496515 +0.0 4 1.5707963267948966 -2.0947125472611012 +0.0 4.5 1.5707963267948966 -2.2093477086153341 +0.0 5 1.5707963267948966 -2.3124383412727525 +;0.5 0.0 1.0471975511965979 -0.0 +0.5 0.5 1.1185178796437059 -0.53063753095251787 +0.5 1 1.2213572639376833 -0.92613303135018232 +0.5 1.5 1.29730903665334 -1.2264568712514059 +0.5 2 1.3497776911720125 -1.4657153519472905 +0.5 2.5 1.3867764005525824 -1.6630597397306994 +0.5 3 1.4137917320059543 -1.8301947623375088 +0.5 3.5 1.4341955764912189 -1.9747225765227623 +0.5 4 1.4500667562979073 -2.1018015246120907 +0.5 4.5 1.4627241156054056 -2.2150603624774576 +0.5 5 1.4730329474299688 -2.3171322930349234 +1 0.0 0.0 -0.0 +1 0.5 0.67488884558600648 -0.73285767597364537 +1 1 0.9045568943023814 -1.0612750619050357 +1 1.5 1.0471975511965976 -1.3169578969248166 +1 2 1.1437177404024206 -1.5285709194809984 +1 2.5 1.2123912958473235 -1.7084532853187295 +1 3 1.2631926772641855 -1.8641615441578825 +1 3.5 1.3020069925537121 -2.0009283853833404 +1 4 1.3324788649850305 -2.1225501238100715 +1 4.5 1.3569558580672694 -2.2318513527511969 +1 5 1.3770031902399644 -2.3309746530493123 +1.5 0.0 0.0 -0.96242365011920694 +1.5 0.5 0.3996390673365241 -1.0693110431581105 +1.5 1 0.66442055082015217 -1.2604751877984541 +1.5 1.5 0.8403951088416709 -1.4497343495853601 +1.5 2 0.96428480859514198 -1.6224941488715938 +1.5 2.5 1.0552478910599898 -1.7776623775066449 +1.5 3 1.1242292777231266 -1.9168395294689364 +1.5 3.5 1.1779555217781177 -2.042121664538171 +1.5 4 1.2207611557752369 -2.1555081001347598 +1.5 4.5 1.2555388691931133 -2.2587403709962968 +1.5 5 1.2842760610181159 -2.3532830725605218 +2 0.0 0.0 -1.3169578969248166 +2 0.5 0.27775425655771396 -1.3618009008578458 +2 1 0.50735630321714453 -1.4693517443681852 +2 1.5 0.68303118061099144 -1.6004100552346137 +2 2 0.81654718209685051 -1.7343245214879666 +2 2.5 0.91943293481682364 -1.8629147540260123 +2 3 1.0001435424737972 -1.9833870299165355 +2 3.5 1.0645947936207991 -2.0951644322598453 +2 4 1.1169261168317741 -2.1985730279209359 +2 4.5 1.1600678294088547 -2.294277166397185 +2 5 1.1961255219693696 -2.3830308809003258 +2.5 0.0 0.0 -1.5667992369724109 +2.5 0.5 0.21396098534132454 -1.5919125928575537 +2.5 1 0.40617281650551157 -1.6586932988564327 +2.5 1.5 0.56743361506164591 -1.7501487613175148 +2.5 2 0.69887812571442653 -1.8522660627003649 +2.5 2.5 0.80537157705837525 -1.9566101076215752 +2.5 3 0.89202761538226805 -2.0587619778850184 +2.5 3.5 0.96315759301770687 -2.156624662472399 +2.5 4 1.022146711243082 -2.2493538620214859 +2.5 4.5 1.0715883556151709 -2.3367597642493152 +2.5 5 1.1134571769983608 -2.4189821813541275 +3 0.0 0.0 -1.7627471740390861 +3 0.5 0.17464646508544929 -1.7789904938267687 +3 1 0.33770110926555247 -1.8241987021938828 +3 1.5 0.48214808473382775 -1.8902413596022003 +3 2 0.60613782238729375 -1.9686379257930964 +3 2.5 0.71099301166950957 -2.05286474223273 +3 3 0.79927813467304831 -2.1386220863162211 +3 3.5 0.87372883284394587 -2.2233202904833753 +3 4 0.93681246115571981 -2.3055090312434769 +3 4.5 0.99060472527214638 -2.3844495098256124 +3 5 1.036797257200728 -2.4598315216234345 +3.5 0.0 0.0 -1.9248473002384137 +3.5 0.5 0.14784102721070985 -1.9362874087060464 +3.5 1 0.2887698569311295 -1.9688930527223867 +3.5 1.5 0.41783334803565009 -2.0183663608257105 +3.5 2 0.53271101891681671 -2.0795673772714314 +3.5 2.5 0.63319582395480256 -2.1478728797685616 +3.5 3 0.7203103731710232 -2.2197264921337307 +3.5 3.5 0.79559870620690554 -2.292639829480557 +3.5 4 0.86070455872300777 -2.3649810177545616 +3.5 4.5 0.91716533955637225 -2.4357376718882664 +3.5 5 0.96633244050378642 -2.504321204197816 +4 0.0 0.0 -2.0634370688955608 +4 0.5 0.12832005450152423 -2.0719611994218501 +4 1 0.25217940871635341 -2.0965964572888911 +4 1.5 0.36806411482882501 -2.1348757684000321 +4 2 0.4738747779647538 -2.1835852165645639 +4 2.5 0.56884710816305495 -2.2395158625112814 +4 3 0.65317947344341798 -2.2999140408792695 +4 3.5 0.72762999925723792 -2.3626333727441886 +4 4 0.79320907467323565 -2.42610665211539 +4 4.5 0.85098534507070622 -2.4892444198251908 +4 5 0.90197975146896925 -2.5513216254756985 +4.5 0.0 0.0 -2.1846437916051089 +4.5 0.5 0.11343363023261466 -2.1912554738875611 +4.5 1 0.22381637001194821 -2.2105337024568841 +4.5 1.5 0.32859934994854589 -2.2409658207528156 +4.5 2 0.42603730470335777 -2.2804665033403291 +4.5 2.5 0.51522845682877461 -2.3267973728501672 +4.5 3 0.59596912458287687 -2.3778787412951385 +4.5 3.5 0.66854000202379782 -2.4319527481396968 +4.5 4 0.7335069086829249 -2.4876280519626373 +4.5 4.5 0.79157021909754721 -2.5438553108375843 +4.5 5 0.84346547238275327 -2.5998730688034706 +5 0.0 0.0 -2.2924316695611777 +5 0.5 0.10168821054536265 -2.2977170809810494 +5 1 0.20119507970091022 -2.3132209417695293 +5 1.5 0.2966254930338259 -2.3379654110880099 +5 2 0.38656464251987466 -2.3705485373179198 +5 2.5 0.47014034964333123 -2.4093853763583719 +5 3 0.54697458028311374 -2.4529137425028118 +5 3.5 0.61707492445882539 -2.4997285620656857 +5 4 0.68071306514378538 -2.5486455784678337 +5 4.5 0.73831846141181878 -2.5987135017717908 +5 5 0.79039774680951247 -2.6491961778064712 +-0.0 -0.0 1.5707963267948966 0.0 +-0.0 -0.5 1.5707963267948966 0.48121182505960342 +-0.0 -1 1.5707963267948966 0.88137358701954305 +-0.0 -1.5 1.5707963267948966 1.1947632172871094 +-0.0 -2 1.5707963267948966 1.4436354751788103 +-0.0 -2.5 1.5707963267948966 1.6472311463710958 +-0.0 -3 1.5707963267948966 1.8184464592320668 +-0.0 -3.5 1.5707963267948966 1.9657204716496515 +-0.0 -4 1.5707963267948966 2.0947125472611012 +-0.0 -4.5 1.5707963267948966 2.2093477086153341 +-0.0 -5 1.5707963267948966 2.3124383412727525 +;-0.5 -0.0 2.0943951023931953 0.0 +-0.5 -0.5 2.023074773946087 0.53063753095251787 +-0.5 -1 1.9202353896521098 0.92613303135018232 +-0.5 -1.5 1.8442836169364532 1.2264568712514059 +-0.5 -2 1.7918149624177806 1.4657153519472905 +-0.5 -2.5 1.7548162530372107 1.6630597397306994 +-0.5 -3 1.7278009215838388 1.8301947623375088 +-0.5 -3.5 1.7073970770985742 1.9747225765227623 +-0.5 -4 1.6915258972918858 2.1018015246120907 +-0.5 -4.5 1.6788685379843875 2.2150603624774576 +-0.5 -5 1.6685597061598243 2.3171322930349234 +-1 -0.0 3.1415926535897931 0.0 +-1 -0.5 2.4667038080037864 0.73285767597364537 +-1 -1 2.2370357592874117 1.0612750619050357 +-1 -1.5 2.0943951023931957 1.3169578969248166 +-1 -2 1.9978749131873725 1.5285709194809984 +-1 -2.5 1.9292013577424696 1.7084532853187295 +-1 -3 1.8783999763256076 1.8641615441578825 +-1 -3.5 1.839585661036081 2.0009283853833404 +-1 -4 1.8091137886047626 2.1225501238100715 +-1 -4.5 1.7846367955225237 2.2318513527511969 +-1 -5 1.7645894633498287 2.3309746530493123 +-1.5 -0.0 3.1415926535897931 0.96242365011920694 +-1.5 -0.5 2.7419535862532691 1.0693110431581105 +-1.5 -1 2.4771721027696412 1.2604751877984541 +-1.5 -1.5 2.3011975447481223 1.4497343495853601 +-1.5 -2 2.177307844994651 1.6224941488715938 +-1.5 -2.5 2.0863447625298033 1.7776623775066449 +-1.5 -3 2.0173633758666663 1.9168395294689364 +-1.5 -3.5 1.9636371318116754 2.042121664538171 +-1.5 -4 1.9208314978145562 2.1555081001347598 +-1.5 -4.5 1.8860537843966798 2.2587403709962968 +-1.5 -5 1.8573165925716772 2.3532830725605218 +-2 -0.0 3.1415926535897931 1.3169578969248166 +-2 -0.5 2.8638383970320791 1.3618009008578458 +-2 -1 2.6342363503726487 1.4693517443681852 +-2 -1.5 2.4585614729788015 1.6004100552346137 +-2 -2 2.3250454714929427 1.7343245214879666 +-2 -2.5 2.2221597187729696 1.8629147540260123 +-2 -3 2.1414491111159961 1.9833870299165355 +-2 -3.5 2.0769978599689942 2.0951644322598453 +-2 -4 2.0246665367580192 2.1985730279209359 +-2 -4.5 1.9815248241809384 2.294277166397185 +-2 -5 1.9454671316204235 2.3830308809003258 +-2.5 -0.0 3.1415926535897931 1.5667992369724109 +-2.5 -0.5 2.9276316682484684 1.5919125928575537 +-2.5 -1 2.7354198370842817 1.6586932988564327 +-2.5 -1.5 2.5741590385281472 1.7501487613175148 +-2.5 -2 2.4427145278753666 1.8522660627003649 +-2.5 -2.5 2.3362210765314178 1.9566101076215752 +-2.5 -3 2.2495650382075252 2.0587619778850184 +-2.5 -3.5 2.1784350605720864 2.156624662472399 +-2.5 -4 2.1194459423467111 2.2493538620214859 +-2.5 -4.5 2.0700042979746223 2.3367597642493152 +-2.5 -5 2.0281354765914323 2.4189821813541275 +-3 -0.0 3.1415926535897931 1.7627471740390861 +-3 -0.5 2.9669461885043438 1.7789904938267687 +-3 -1 2.8038915443242405 1.8241987021938828 +-3 -1.5 2.6594445688559656 1.8902413596022003 +-3 -2 2.5354548312024994 1.9686379257930964 +-3 -2.5 2.4305996419202835 2.05286474223273 +-3 -3 2.3423145189167447 2.1386220863162211 +-3 -3.5 2.2678638207458475 2.2233202904833753 +-3 -4 2.2047801924340735 2.3055090312434769 +-3 -4.5 2.1509879283176465 2.3844495098256124 +-3 -5 2.1047953963890649 2.4598315216234345 +-3.5 -0.0 3.1415926535897931 1.9248473002384137 +-3.5 -0.5 2.9937516263790833 1.9362874087060464 +-3.5 -1 2.8528227966586637 1.9688930527223867 +-3.5 -1.5 2.7237593055541431 2.0183663608257105 +-3.5 -2 2.6088816346729766 2.0795673772714314 +-3.5 -2.5 2.5083968296349903 2.1478728797685616 +-3.5 -3 2.4212822804187697 2.2197264921337307 +-3.5 -3.5 2.3459939473828877 2.292639829480557 +-3.5 -4 2.2808880948667856 2.3649810177545616 +-3.5 -4.5 2.224427314033421 2.4357376718882664 +-3.5 -5 2.1752602130860068 2.504321204197816 +-4 -0.0 3.1415926535897931 2.0634370688955608 +-4 -0.5 3.0132725990882689 2.0719611994218501 +-4 -1 2.8894132448734395 2.0965964572888911 +-4 -1.5 2.7735285387609681 2.1348757684000321 +-4 -2 2.6677178756250393 2.1835852165645639 +-4 -2.5 2.5727455454267383 2.2395158625112814 +-4 -3 2.4884131801463751 2.2999140408792695 +-4 -3.5 2.413962654332555 2.3626333727441886 +-4 -4 2.3483835789165575 2.42610665211539 +-4 -4.5 2.2906073085190868 2.4892444198251908 +-4 -5 2.239612902120824 2.5513216254756985 +-4.5 -0.0 3.1415926535897931 2.1846437916051089 +-4.5 -0.5 3.0281590233571785 2.1912554738875611 +-4.5 -1 2.9177762835778447 2.2105337024568841 +-4.5 -1.5 2.8129933036412473 2.2409658207528156 +-4.5 -2 2.7155553488864355 2.2804665033403291 +-4.5 -2.5 2.6263641967610187 2.3267973728501672 +-4.5 -3 2.5456235290069165 2.3778787412951385 +-4.5 -3.5 2.4730526515659954 2.4319527481396968 +-4.5 -4 2.4080857449068684 2.4876280519626373 +-4.5 -4.5 2.3500224344922458 2.5438553108375843 +-4.5 -5 2.2981271812070396 2.5998730688034706 +-5 -0.0 3.1415926535897931 2.2924316695611777 +-5 -0.5 3.0399044430444304 2.2977170809810494 +-5 -1 2.940397573888883 2.3132209417695293 +-5 -1.5 2.8449671605559672 2.3379654110880099 +-5 -2 2.7550280110699186 2.3705485373179198 +-5 -2.5 2.6714523039464617 2.4093853763583719 +-5 -3 2.5946180733066795 2.4529137425028118 +-5 -3.5 2.5245177291309675 2.4997285620656857 +-5 -4 2.4608795884460077 2.5486455784678337 +-5 -4.5 2.4032741921779746 2.5987135017717908 +-5 -5 2.3511949067802806 2.6491961778064712 diff --git a/commons-numbers-complex/src/test/resources/data/acosh.txt b/commons-numbers-complex/src/test/resources/data/acosh.txt new file mode 100644 index 0000000..c31d1f4 --- /dev/null +++ b/commons-numbers-complex/src/test/resources/data/acosh.txt @@ -0,0 +1,243 @@ +# (a + b i) acosh(a + b i) +0.0 0.0 0.0 1.5707963267948966 +0.0 0.5 0.48121182505960342 1.5707963267948966 +0.0 1 0.88137358701954305 1.5707963267948966 +0.0 1.5 1.1947632172871094 1.5707963267948966 +0.0 2 1.4436354751788103 1.5707963267948966 +0.0 2.5 1.6472311463710958 1.5707963267948966 +0.0 3 1.8184464592320668 1.5707963267948966 +0.0 3.5 1.9657204716496515 1.5707963267948966 +0.0 4 2.0947125472611012 1.5707963267948966 +0.0 4.5 2.2093477086153341 1.5707963267948966 +0.0 5 2.3124383412727525 1.5707963267948966 +;0.5 0.0 0.0 1.0471975511965979 +0.5 0.5 0.53063753095251787 1.1185178796437059 +0.5 1 0.92613303135018232 1.2213572639376833 +0.5 1.5 1.2264568712514059 1.29730903665334 +0.5 2 1.4657153519472905 1.3497776911720125 +0.5 2.5 1.6630597397306994 1.3867764005525824 +0.5 3 1.8301947623375088 1.4137917320059543 +0.5 3.5 1.9747225765227623 1.4341955764912189 +0.5 4 2.1018015246120907 1.4500667562979073 +0.5 4.5 2.2150603624774576 1.4627241156054056 +0.5 5 2.3171322930349234 1.4730329474299688 +1 0.0 0.0 0.0 +1 0.5 0.73285767597364537 0.67488884558600648 +1 1 1.0612750619050357 0.9045568943023814 +1 1.5 1.3169578969248166 1.0471975511965976 +1 2 1.5285709194809984 1.1437177404024206 +1 2.5 1.7084532853187295 1.2123912958473235 +1 3 1.8641615441578825 1.2631926772641855 +1 3.5 2.0009283853833404 1.3020069925537121 +1 4 2.1225501238100715 1.3324788649850305 +1 4.5 2.2318513527511969 1.3569558580672694 +1 5 2.3309746530493123 1.3770031902399644 +1.5 0.0 0.96242365011920694 0.0 +1.5 0.5 1.0693110431581105 0.3996390673365241 +1.5 1 1.2604751877984541 0.66442055082015217 +1.5 1.5 1.4497343495853601 0.8403951088416709 +1.5 2 1.6224941488715938 0.96428480859514198 +1.5 2.5 1.7776623775066449 1.0552478910599898 +1.5 3 1.9168395294689364 1.1242292777231266 +1.5 3.5 2.042121664538171 1.1779555217781177 +1.5 4 2.1555081001347598 1.2207611557752369 +1.5 4.5 2.2587403709962968 1.2555388691931133 +1.5 5 2.3532830725605218 1.2842760610181159 +2 0.0 1.3169578969248166 0.0 +2 0.5 1.3618009008578458 0.27775425655771396 +2 1 1.4693517443681852 0.50735630321714453 +2 1.5 1.6004100552346137 0.68303118061099144 +2 2 1.7343245214879666 0.81654718209685051 +2 2.5 1.8629147540260123 0.91943293481682364 +2 3 1.9833870299165355 1.0001435424737972 +2 3.5 2.0951644322598453 1.0645947936207991 +2 4 2.1985730279209359 1.1169261168317741 +2 4.5 2.294277166397185 1.1600678294088547 +2 5 2.3830308809003258 1.1961255219693696 +2.5 0.0 1.5667992369724109 0.0 +2.5 0.5 1.5919125928575537 0.21396098534132454 +2.5 1 1.6586932988564327 0.40617281650551157 +2.5 1.5 1.7501487613175148 0.56743361506164591 +2.5 2 1.8522660627003649 0.69887812571442653 +2.5 2.5 1.9566101076215752 0.80537157705837525 +2.5 3 2.0587619778850184 0.89202761538226805 +2.5 3.5 2.156624662472399 0.96315759301770687 +2.5 4 2.2493538620214859 1.022146711243082 +2.5 4.5 2.3367597642493152 1.0715883556151709 +2.5 5 2.4189821813541275 1.1134571769983608 +3 0.0 1.7627471740390861 0.0 +3 0.5 1.7789904938267687 0.17464646508544929 +3 1 1.8241987021938828 0.33770110926555247 +3 1.5 1.8902413596022003 0.48214808473382775 +3 2 1.9686379257930964 0.60613782238729375 +3 2.5 2.05286474223273 0.71099301166950957 +3 3 2.1386220863162211 0.79927813467304831 +3 3.5 2.2233202904833753 0.87372883284394587 +3 4 2.3055090312434769 0.93681246115571981 +3 4.5 2.3844495098256124 0.99060472527214638 +3 5 2.4598315216234345 1.036797257200728 +3.5 0.0 1.9248473002384137 0.0 +3.5 0.5 1.9362874087060464 0.14784102721070985 +3.5 1 1.9688930527223867 0.2887698569311295 +3.5 1.5 2.0183663608257105 0.41783334803565009 +3.5 2 2.0795673772714314 0.53271101891681671 +3.5 2.5 2.1478728797685616 0.63319582395480256 +3.5 3 2.2197264921337307 0.7203103731710232 +3.5 3.5 2.292639829480557 0.79559870620690554 +3.5 4 2.3649810177545616 0.86070455872300777 +3.5 4.5 2.4357376718882664 0.91716533955637225 +3.5 5 2.504321204197816 0.96633244050378642 +4 0.0 2.0634370688955608 0.0 +4 0.5 2.0719611994218501 0.12832005450152423 +4 1 2.0965964572888911 0.25217940871635341 +4 1.5 2.1348757684000321 0.36806411482882501 +4 2 2.1835852165645639 0.4738747779647538 +4 2.5 2.2395158625112814 0.56884710816305495 +4 3 2.2999140408792695 0.65317947344341798 +4 3.5 2.3626333727441886 0.72762999925723792 +4 4 2.42610665211539 0.79320907467323565 +4 4.5 2.4892444198251908 0.85098534507070622 +4 5 2.5513216254756985 0.90197975146896925 +4.5 0.0 2.1846437916051089 0.0 +4.5 0.5 2.1912554738875611 0.11343363023261466 +4.5 1 2.2105337024568841 0.22381637001194821 +4.5 1.5 2.2409658207528156 0.32859934994854589 +4.5 2 2.2804665033403291 0.42603730470335777 +4.5 2.5 2.3267973728501672 0.51522845682877461 +4.5 3 2.3778787412951385 0.59596912458287687 +4.5 3.5 2.4319527481396968 0.66854000202379782 +4.5 4 2.4876280519626373 0.7335069086829249 +4.5 4.5 2.5438553108375843 0.79157021909754721 +4.5 5 2.5998730688034706 0.84346547238275327 +5 0.0 2.2924316695611777 0.0 +5 0.5 2.2977170809810494 0.10168821054536265 +5 1 2.3132209417695293 0.20119507970091022 +5 1.5 2.3379654110880099 0.2966254930338259 +5 2 2.3705485373179198 0.38656464251987466 +5 2.5 2.4093853763583719 0.47014034964333123 +5 3 2.4529137425028118 0.54697458028311374 +5 3.5 2.4997285620656857 0.61707492445882539 +5 4 2.5486455784678337 0.68071306514378538 +5 4.5 2.5987135017717908 0.73831846141181878 +5 5 2.6491961778064712 0.79039774680951247 +-0.0 -0.0 0.0 -1.5707963267948966 +-0.0 -0.5 0.48121182505960342 -1.5707963267948966 +-0.0 -1 0.88137358701954305 -1.5707963267948966 +-0.0 -1.5 1.1947632172871094 -1.5707963267948966 +-0.0 -2 1.4436354751788103 -1.5707963267948966 +-0.0 -2.5 1.6472311463710958 -1.5707963267948966 +-0.0 -3 1.8184464592320668 -1.5707963267948966 +-0.0 -3.5 1.9657204716496515 -1.5707963267948966 +-0.0 -4 2.0947125472611012 -1.5707963267948966 +-0.0 -4.5 2.2093477086153341 -1.5707963267948966 +-0.0 -5 2.3124383412727525 -1.5707963267948966 +;-0.5 -0.0 0.0 -2.0943951023931953 +-0.5 -0.5 0.53063753095251787 -2.023074773946087 +-0.5 -1 0.92613303135018232 -1.9202353896521098 +-0.5 -1.5 1.2264568712514059 -1.8442836169364532 +-0.5 -2 1.4657153519472905 -1.7918149624177806 +-0.5 -2.5 1.6630597397306994 -1.7548162530372107 +-0.5 -3 1.8301947623375088 -1.7278009215838388 +-0.5 -3.5 1.9747225765227623 -1.7073970770985742 +-0.5 -4 2.1018015246120907 -1.6915258972918858 +-0.5 -4.5 2.2150603624774576 -1.6788685379843875 +-0.5 -5 2.3171322930349234 -1.6685597061598243 +-1 -0.0 0.0 -3.1415926535897931 +-1 -0.5 0.73285767597364537 -2.4667038080037864 +-1 -1 1.0612750619050357 -2.2370357592874117 +-1 -1.5 1.3169578969248166 -2.0943951023931957 +-1 -2 1.5285709194809984 -1.9978749131873725 +-1 -2.5 1.7084532853187295 -1.9292013577424696 +-1 -3 1.8641615441578825 -1.8783999763256076 +-1 -3.5 2.0009283853833404 -1.839585661036081 +-1 -4 2.1225501238100715 -1.8091137886047626 +-1 -4.5 2.2318513527511969 -1.7846367955225237 +-1 -5 2.3309746530493123 -1.7645894633498287 +-1.5 -0.0 0.96242365011920694 -3.1415926535897931 +-1.5 -0.5 1.0693110431581105 -2.7419535862532691 +-1.5 -1 1.2604751877984541 -2.4771721027696412 +-1.5 -1.5 1.4497343495853601 -2.3011975447481223 +-1.5 -2 1.6224941488715938 -2.177307844994651 +-1.5 -2.5 1.7776623775066449 -2.0863447625298033 +-1.5 -3 1.9168395294689364 -2.0173633758666663 +-1.5 -3.5 2.042121664538171 -1.9636371318116754 +-1.5 -4 2.1555081001347598 -1.9208314978145562 +-1.5 -4.5 2.2587403709962968 -1.8860537843966798 +-1.5 -5 2.3532830725605218 -1.8573165925716772 +-2 -0.0 1.3169578969248166 -3.1415926535897931 +-2 -0.5 1.3618009008578458 -2.8638383970320791 +-2 -1 1.4693517443681852 -2.6342363503726487 +-2 -1.5 1.6004100552346137 -2.4585614729788015 +-2 -2 1.7343245214879666 -2.3250454714929427 +-2 -2.5 1.8629147540260123 -2.2221597187729696 +-2 -3 1.9833870299165355 -2.1414491111159961 +-2 -3.5 2.0951644322598453 -2.0769978599689942 +-2 -4 2.1985730279209359 -2.0246665367580192 +-2 -4.5 2.294277166397185 -1.9815248241809384 +-2 -5 2.3830308809003258 -1.9454671316204235 +-2.5 -0.0 1.5667992369724109 -3.1415926535897931 +-2.5 -0.5 1.5919125928575537 -2.9276316682484684 +-2.5 -1 1.6586932988564327 -2.7354198370842817 +-2.5 -1.5 1.7501487613175148 -2.5741590385281472 +-2.5 -2 1.8522660627003649 -2.4427145278753666 +-2.5 -2.5 1.9566101076215752 -2.3362210765314178 +-2.5 -3 2.0587619778850184 -2.2495650382075252 +-2.5 -3.5 2.156624662472399 -2.1784350605720864 +-2.5 -4 2.2493538620214859 -2.1194459423467111 +-2.5 -4.5 2.3367597642493152 -2.0700042979746223 +-2.5 -5 2.4189821813541275 -2.0281354765914323 +-3 -0.0 1.7627471740390861 -3.1415926535897931 +-3 -0.5 1.7789904938267687 -2.9669461885043438 +-3 -1 1.8241987021938828 -2.8038915443242405 +-3 -1.5 1.8902413596022003 -2.6594445688559656 +-3 -2 1.9686379257930964 -2.5354548312024994 +-3 -2.5 2.05286474223273 -2.4305996419202835 +-3 -3 2.1386220863162211 -2.3423145189167447 +-3 -3.5 2.2233202904833753 -2.2678638207458475 +-3 -4 2.3055090312434769 -2.2047801924340735 +-3 -4.5 2.3844495098256124 -2.1509879283176465 +-3 -5 2.4598315216234345 -2.1047953963890649 +-3.5 -0.0 1.9248473002384137 -3.1415926535897931 +-3.5 -0.5 1.9362874087060464 -2.9937516263790833 +-3.5 -1 1.9688930527223867 -2.8528227966586637 +-3.5 -1.5 2.0183663608257105 -2.7237593055541431 +-3.5 -2 2.0795673772714314 -2.6088816346729766 +-3.5 -2.5 2.1478728797685616 -2.5083968296349903 +-3.5 -3 2.2197264921337307 -2.4212822804187697 +-3.5 -3.5 2.292639829480557 -2.3459939473828877 +-3.5 -4 2.3649810177545616 -2.2808880948667856 +-3.5 -4.5 2.4357376718882664 -2.224427314033421 +-3.5 -5 2.504321204197816 -2.1752602130860068 +-4 -0.0 2.0634370688955608 -3.1415926535897931 +-4 -0.5 2.0719611994218501 -3.0132725990882689 +-4 -1 2.0965964572888911 -2.8894132448734395 +-4 -1.5 2.1348757684000321 -2.7735285387609681 +-4 -2 2.1835852165645639 -2.6677178756250393 +-4 -2.5 2.2395158625112814 -2.5727455454267383 +-4 -3 2.2999140408792695 -2.4884131801463751 +-4 -3.5 2.3626333727441886 -2.413962654332555 +-4 -4 2.42610665211539 -2.3483835789165575 +-4 -4.5 2.4892444198251908 -2.2906073085190868 +-4 -5 2.5513216254756985 -2.239612902120824 +-4.5 -0.0 2.1846437916051089 -3.1415926535897931 +-4.5 -0.5 2.1912554738875611 -3.0281590233571785 +-4.5 -1 2.2105337024568841 -2.9177762835778447 +-4.5 -1.5 2.2409658207528156 -2.8129933036412473 +-4.5 -2 2.2804665033403291 -2.7155553488864355 +-4.5 -2.5 2.3267973728501672 -2.6263641967610187 +-4.5 -3 2.3778787412951385 -2.5456235290069165 +-4.5 -3.5 2.4319527481396968 -2.4730526515659954 +-4.5 -4 2.4876280519626373 -2.4080857449068684 +-4.5 -4.5 2.5438553108375843 -2.3500224344922458 +-4.5 -5 2.5998730688034706 -2.2981271812070396 +-5 -0.0 2.2924316695611777 -3.1415926535897931 +-5 -0.5 2.2977170809810494 -3.0399044430444304 +-5 -1 2.3132209417695293 -2.940397573888883 +-5 -1.5 2.3379654110880099 -2.8449671605559672 +-5 -2 2.3705485373179198 -2.7550280110699186 +-5 -2.5 2.4093853763583719 -2.6714523039464617 +-5 -3 2.4529137425028118 -2.5946180733066795 +-5 -3.5 2.4997285620656857 -2.5245177291309675 +-5 -4 2.5486455784678337 -2.4608795884460077 +-5 -4.5 2.5987135017717908 -2.4032741921779746 +-5 -5 2.6491961778064712 -2.3511949067802806 diff --git a/commons-numbers-complex/src/test/resources/data/asinh.txt b/commons-numbers-complex/src/test/resources/data/asinh.txt new file mode 100644 index 0000000..f9348e1 --- /dev/null +++ b/commons-numbers-complex/src/test/resources/data/asinh.txt @@ -0,0 +1,122 @@ +# (a + b i) asinh(a + b i) +0.0 0.0 0.0 0.0 +;0.0 0.5 0.0 0.52359877559829893 +0.0 1 0.0 1.5707963267948966 +0.0 1.5 0.96242365011920694 1.5707963267948966 +0.0 2 1.3169578969248166 1.5707963267948966 +0.0 2.5 1.5667992369724109 1.5707963267948966 +0.0 3 1.7627471740390861 1.5707963267948966 +0.0 3.5 1.9248473002384137 1.5707963267948966 +0.0 4 2.0634370688955608 1.5707963267948966 +0.0 4.5 2.1846437916051089 1.5707963267948966 +0.0 5 2.2924316695611777 1.5707963267948966 +0.5 0.0 0.48121182505960342 0.0 +0.5 0.5 0.53063753095251787 0.45227844715119064 +0.5 1 0.73285767597364537 0.89590748120889019 +0.5 1.5 1.0693110431581105 1.1711572594583726 +0.5 2 1.3618009008578458 1.2930420702371825 +0.5 2.5 1.5919125928575537 1.3568353414535721 +0.5 3 1.7789904938267687 1.3961498617094474 +0.5 3.5 1.9362874087060464 1.4229552995841868 +0.5 4 2.0719611994218501 1.4424762722933724 +0.5 4.5 2.1912554738875611 1.4573626965622819 +0.5 5 2.2977170809810494 1.4691081162495341 +1 0.0 0.88137358701954305 0.0 +1 0.5 0.92613303135018232 0.34943906285721332 +1 1 1.0612750619050357 0.66623943249251527 +1 1.5 1.2604751877984541 0.90637577597474439 +1 2 1.4693517443681852 1.0634400235777519 +1 2.5 1.6586932988564327 1.1646235102893852 +1 3 1.8241987021938828 1.2330952175293441 +1 3.5 1.9688930527223867 1.2820264698637671 +1 4 2.0965964572888911 1.3186169180785432 +1 4.5 2.2105337024568841 1.3469799567829484 +1 5 2.3132209417695293 1.3696012470939865 +1.5 0.0 1.1947632172871094 0.0 +1.5 0.5 1.2264568712514059 0.27348729014155682 +1.5 1 1.3169578969248166 0.52359877559829893 +1.5 1.5 1.4497343495853601 0.73040121795322566 +1.5 2 1.6004100552346137 0.88776514618390501 +1.5 2.5 1.7501487613175148 1.0033627117332509 +1.5 3 1.8902413596022003 1.0886482420610688 +1.5 3.5 2.0183663608257105 1.1529629787592466 +1.5 4 2.1348757684000321 1.2027322119660715 +1.5 4.5 2.2409658207528156 1.2421969768463508 +1.5 5 2.3379654110880099 1.2741708337610707 +2 0.0 1.4436354751788103 0.0 +2 0.5 1.4657153519472905 0.22101863562288385 +2 1 1.5285709194809984 0.42707858639247603 +2 1.5 1.6224941488715938 0.60651151819975468 +2 2 1.7343245214879666 0.75424914469804594 +2 2.5 1.8522660627003649 0.87191820108047002 +2 3 1.9686379257930964 0.96465850440760281 +2 3.5 2.0795673772714314 1.0380853078780798 +2 4 2.1835852165645639 1.0969215488301429 +2 4.5 2.2804665033403291 1.1447590220915389 +2 5 2.3705485373179198 1.184231684275022 +2.5 0.0 1.6472311463710958 0.0 +2.5 0.5 1.6630597397306994 0.18401992624231417 +2.5 1 1.7084532853187295 0.3584050309475732 +2.5 1.5 1.7776623775066449 0.51554843573490672 +2.5 2 1.8629147540260123 0.65136339197807303 +2.5 2.5 1.9566101076215752 0.76542474973652141 +2.5 3 2.05286474223273 0.8598033151253871 +2.5 3.5 2.1478728797685616 0.937600502840094 +2.5 4 2.2395158625112814 1.0019492186318415 +2.5 4.5 2.3267973728501672 1.0555678699661222 +2.5 5 2.4093853763583719 1.1006559771515654 +3 0.0 1.8184464592320668 0.0 +3 0.5 1.8301947623375088 0.15700459478894233 +3 1 1.8641615441578825 0.30760364953071123 +3 1.5 1.9168395294689364 0.44656704907176997 +3 2 1.9833870299165355 0.57065278432109945 +3 2.5 2.0587619778850184 0.67876871141262851 +3 3 2.1386220863162211 0.77151819212184836 +3 3.5 2.2197264921337307 0.85048595362387336 +3 4 2.2999140408792695 0.91761685335147869 +3 4.5 2.3778787412951385 0.97482720221201979 +3 5 2.4529137425028118 1.0238217465117829 +3.5 0.0 1.9657204716496515 0.0 +3.5 0.5 1.9747225765227623 0.13660075030367758 +3.5 1 2.0009283853833404 0.26878933424118456 +3.5 1.5 2.042121664538171 0.39284080501677876 +3.5 2 2.0951644322598453 0.50620153317409755 +3.5 2.5 2.156624662472399 0.60763873377718969 +3.5 3 2.2233202904833753 0.69706749395095091 +3.5 3.5 2.292639829480557 0.77519762058799102 +3.5 4 2.3626333727441886 0.84316632753765874 +3.5 4.5 2.4319527481396968 0.90225632477109885 +3.5 5 2.4997285620656857 0.95372140233607117 +4 0.0 2.0947125472611012 0.0 +4 0.5 2.1018015246120907 0.12072957049698953 +4 1 2.1225501238100715 0.2383174618098661 +4 1.5 2.1555081001347598 0.35003517101965975 +4 2 2.1985730279209359 0.4538702099631225 +4 2.5 2.2493538620214859 0.54864961555181468 +4 3 2.3055090312434769 0.63398386563917664 +4 3.5 2.3649810177545616 0.71009176807188878 +4 4 2.42610665211539 0.77758725212166091 +4 4.5 2.4876280519626373 0.83728941811197177 +4 5 2.5486455784678337 0.89008326165111129 +4.5 0.0 2.2093477086153341 0.0 +4.5 0.5 2.2150603624774576 0.1080722111894912 +4.5 1 2.2318513527511969 0.21384046872762721 +4.5 1.5 2.2587403709962968 0.3152574576017832 +4.5 2 2.294277166397185 0.41072849738604167 +4.5 2.5 2.3367597642493152 0.49920797117972582 +4.5 3 2.3844495098256124 0.58019160152275018 +4.5 3.5 2.4357376718882664 0.65363098723852442 +4.5 4 2.4892444198251908 0.71981098172419022 +4.5 4.5 2.5438553108375843 0.77922610769734935 +4.5 5 2.5987135017717908 0.83247786538307789 +5 0.0 2.3124383412727525 0.0 +5 0.5 2.3171322930349234 0.097763379364927738 +5 1 2.3309746530493123 0.19379313655493219 +5 1.5 2.3532830725605218 0.28652026577678052 +5 2 2.3830308809003258 0.374670804825527 +5 2.5 2.4189821813541275 0.45733914979653584 +5 3 2.4598315216234345 0.53399906959416865 +5 3.5 2.504321204197816 0.60446388629111025 +5 4 2.5513216254756985 0.66881657532592731 +5 4.5 2.5998730688034706 0.72733085441214329 +5 5 2.6491961778064712 0.7803985799853842 diff --git a/commons-numbers-complex/src/test/resources/data/atanh.txt b/commons-numbers-complex/src/test/resources/data/atanh.txt new file mode 100644 index 0000000..c919d2e --- /dev/null +++ b/commons-numbers-complex/src/test/resources/data/atanh.txt @@ -0,0 +1,122 @@ +# (a + b i) atanh(a + b i) +0.0 0.0 0.0 0.0 +0.0 0.5 0.0 0.46364760900080609 +0.0 1 0.0 0.78539816339744828 +0.0 1.5 0.0 0.98279372324732905 +0.0 2 0.0 1.1071487177940904 +0.0 2.5 0.0 1.1902899496825317 +0.0 3 0.0 1.2490457723982544 +0.0 3.5 0.0 1.2924966677897853 +0.0 4 0.0 1.3258176636680326 +0.0 4.5 0.0 1.3521273809209546 +0.0 5 0.0 1.3734007669450159 +0.5 0.0 0.54930614433405489 0.0 +0.5 0.5 0.40235947810852507 0.5535743588970452 +0.5 1 0.23887786125685909 0.84757566067082901 +0.5 1.5 0.14694666622552977 1.0172219678978514 +0.5 2 0.096415620202996169 1.1265564408348223 +0.5 2.5 0.067065996648669843 1.2018887967346641 +0.5 3 0.048936144281523826 1.2563981835871803 +0.5 3.5 0.037105001279568318 1.2974019063502729 +0.5 4 0.029018042813188503 1.3292334943862298 +0.5 4.5 0.023272605766502988 1.3545924390096278 +0.5 5 0.019056841346971064 1.375233603310382 +;1 0.0 Infinity 0.78539816339744828 +1 0.5 0.70830333601405393 0.90788749496088028 +1 1 0.40235947810852507 1.0172219678978514 +1 1.5 0.25541281188299547 1.1071487177940904 +1 2 0.17328679513998629 1.1780972450961724 +1 2.5 0.12367406045902667 1.2334258556831201 +1 3 0.091931195031329432 1.2767950250211129 +1 3.5 0.070641742946252611 1.311223269671635 +1 4 0.055785887828552413 1.3389725222944935 +1 4.5 0.045065455957736186 1.361684162005282 +1 5 0.037105001279568284 1.3805431382387141 +1.5 0.0 0.80471895621705014 1.5707963267948966 +1.5 0.5 0.64123733936538418 1.2767950250211129 +1.5 1 0.43946447938809341 1.2074751564540338 +1.5 1.5 0.30594385790552892 1.2164831907310616 +1.5 2 0.22008968066202295 1.2452579660726568 +1.5 2.5 0.16348161685166601 1.2767950250211129 +1.5 3 0.12498898788227171 1.3060015274038583 +1.5 3.5 0.098010521944005932 1.3316201111055679 +1.5 4 0.078562274959125683 1.3536741663964962 +1.5 4.5 0.064179961711953504 1.3725756851856759 +1.5 5 0.053298305115260416 1.3888068485400746 +2 0.0 0.54930614433405489 1.5707963267948966 +2 0.5 0.50037000005253107 1.4215468610018069 +2 1 0.40235947810852507 1.3389725222944935 +2 1.5 0.31042828307719578 1.311223269671635 +2 2 0.23887786125685909 1.311223269671635 +2 2.5 0.1858945085467093 1.3230204900519824 +2 3 0.14694666622552977 1.3389725222944935 +2 3.5 0.11808983573454865 1.3556330202336171 +2 4 0.096415620202996169 1.3715351039616865 +2 4.5 0.079880669576859922 1.3861294979580838 +2 5 0.067065996648669843 1.399284356584545 +2.5 0.0 0.42364893019360184 1.5707963267948966 +2.5 0.5 0.40235947810852507 1.4808695768986575 +2.5 1 0.35133563902264631 1.4159448545236686 +2.5 1.5 0.29251781316256364 1.3805431382387141 +2.5 2 0.23887786125685909 1.3667217749173519 +2.5 2.5 0.1944261421470021 1.3657326565241512 +2.5 3 0.15899719167999918 1.3715351039616865 +2.5 3.5 0.13113111703103816 1.3805431382387141 +2.5 4 0.10923209439098736 1.3907666621193704 +2.5 4.5 0.091931195031329335 1.4011500195678743 +2.5 5 0.078149605929078853 1.4111617418392259 +3 0.0 0.34657359027997264 1.5707963267948966 +3 0.5 0.33529348145985527 1.5104844925048453 +3 1 0.30594385790552892 1.4614618538579256 +3 1.5 0.2678959040700476 1.4284311075335405 +3 2 0.22907268296853878 1.4099210495965755 +3 2.5 0.19376607575695801 1.4020682921810059 +3 3 0.16348161685166601 1.4011500195678743 +3 3.5 0.13825013720417587 1.4043862203315221 +3 4 0.11750090731143388 1.4099210495965755 +3 4.5 0.1005056909792979 1.4165873212436484 +3 5 0.086569059179458438 1.4236790442393028 +3.5 0.0 0.29389333245105953 1.5707963267948966 +3.5 0.5 0.28715567731069275 1.527427157456904 +3.5 1 0.26883885662596063 1.4898776111756851 +3.5 1.5 0.24336228642852592 1.4614618538579256 +3.5 2 0.21528472794976877 1.4425380204727349 +3.5 2.5 0.18785402217098029 1.4316464972923408 +3.5 3 0.16282501765611121 1.4267686032695837 +3.5 3.5 0.14086733931285317 1.4260444908142025 +3.5 4 0.12202434317210864 1.4280189914100923 +3.5 4.5 0.10603931028007924 1.4316464972923408 +3.5 5 0.092545823490881154 1.4362125804020465 +4 0.0 0.25541281188299531 1.5707963267948966 +4 0.5 0.25105065104925878 1.5380563143331643 +4 1 0.23887786125685909 1.5086188295215159 +4 1.5 0.22117134811470598 1.4847009195334271 +4 2 0.20058661813123432 1.4670482135772953 +4 2.5 0.17935996828224748 1.4552509931969482 +4 3 0.15899719167999918 1.4483069952314644 +4 3.5 0.14032376236378566 1.4450742816558877 +4 4 0.12367406045902676 1.4445191889058668 +4 4.5 0.10908077411701741 1.4458070160644854 +4 5 0.096415620202996169 1.4483069952314644 +4.5 0.0 0.22599256187152864 1.5707963267948966 +4.5 0.5 0.22299950982627761 1.5451777430931872 +4.5 1 0.2145054559375448 1.5215732471885801 +4.5 1.5 0.20177285997729077 1.5014764582278175 +4.5 2 0.18639841398312196 1.4856087714635886 +4.5 2.5 0.16988538212604168 1.4739853303669239 +4.5 3 0.1533986372144979 1.4661565515711266 +4.5 3.5 0.13770773959492247 1.4614618538579256 +4.5 4 0.12324200159149606 1.4592113064159771 +4.5 4.5 0.1101833117364056 1.4587845032759348 +4.5 5 0.098554098893073427 1.459668675652285 +5 0.0 0.20273255405408219 1.5707963267948966 +5 0.5 0.20058661813123432 1.5501894454657366 +5 1 0.1944261421470021 1.5308813339387779 +5 1.5 0.18499462006101108 1.5139003232230426 +5 2 0.17328679513998632 1.4998477994928145 +5 2.5 0.1603155862977334 1.4888922289729962 +5 3 0.14694666622552977 1.4808695768986575 +5 3.5 0.13382559254813625 1.4754185511972642 +5 4 0.12137695394542521 1.4720985468699563 +5 4.5 0.10984166494596143 1.4704698881349534 +5 5 0.099325449367250865 1.4701377726075762 diff --git a/commons-numbers-complex/src/test/resources/data/cosh.txt b/commons-numbers-complex/src/test/resources/data/cosh.txt new file mode 100644 index 0000000..697aa97 --- /dev/null +++ b/commons-numbers-complex/src/test/resources/data/cosh.txt @@ -0,0 +1,122 @@ +# (a + b i) cosh(a + b i) +0.0 0.0 1 0.0 +0.0 0.5 0.87758256189037276 0.0 +0.0 1 0.54030230586813977 0.0 +0.0 1.5 0.070737201667702906 0.0 +0.0 2 -0.41614683654714241 0.0 +0.0 2.5 -0.8011436155469337 0.0 +0.0 3 -0.98999249660044542 0.0 +0.0 3.5 -0.93645668729079634 0.0 +0.0 4 -0.65364362086361194 0.0 +0.0 4.5 -0.21079579943077972 0.0 +0.0 5 0.2836621854632263 0.0 +0.5 0.0 1.1276259652063807 0.0 +0.5 0.5 0.9895848833999199 0.24982639750046154 +0.5 1 0.60925890915779424 0.43848657989259532 +0.5 1.5 0.079765105306541892 0.51978995477292123 +0.5 2 -0.46925797822905341 0.473830620416407 +0.5 2.5 -0.90339034275004071 0.31186102476134919 +0.5 3 -1.1163412445261518 0.073536973711236603 +0.5 3.5 -1.055972875880254 -0.18279149319500521 +0.5 4 -0.73706551887732397 -0.39436622749091516 +0.5 4.5 -0.23769881679458363 -0.50938635529403253 +0.5 5 0.31986484567552192 -0.49969093785095825 +1 0.0 1.5430806348152437 0.0 +1 0.5 1.3541806567045842 0.5634214652309818 +1 1 0.83373002513114913 0.98889770576286506 +1 1.5 0.10915320605445292 1.1722572989107924 +1 2 -0.64214812471551996 1.0686074213827783 +1 2.5 -1.2362291988563421 0.70332517811353468 +1 3 -1.5276382501165433 0.16584440191897881 +1 3.5 -1.4450281795016622 -0.41224086789106656 +1 4 -1.0086248134251568 -0.88939519583848459 +1 4.5 -0.32527491600203434 -1.1487945611027877 +1 5 0.43771362521767465 -1.1269289521981367 +1.5 0.0 2.3524096152432472 0.0 +1.5 0.5 2.0644336567607149 1.0208309495976966 +1.5 1 1.2710123394623098 1.7917268800098571 +1.5 1.5 0.16640287335850498 2.123945581536093 +1.5 2 -0.97894781964655775 1.9361483295105071 +1.5 2.5 -1.8846179444033462 1.2743144408870994 +1.5 3 -2.3288678680215553 0.3004839338646903 +1.5 3.5 -2.2029297154417082 -0.74691551991135496 +1.5 4 -1.5376375386619723 -1.6114440048236633 +1.5 4.5 -0.49587806543385327 -2.0814347962807105 +1.5 5 0.66728965256460682 -2.0418177570319203 +2 0.0 3.7621956910836314 0.0 +2 0.5 3.3016373329140944 1.7388095044743164 +2 1 2.0327230070196656 3.0518977991518002 +2 1.5 0.26612719531354573 3.6177750739401375 +2 2 -1.5656258353157435 3.297894836311237 +2 2.5 -3.0140590583498352 2.1705749246499555 +2 3 -3.7245455049153224 0.51182256998738462 +2 3.5 -3.5231333138118854 -1.2722418002442684 +2 4 -2.4591352139173837 -2.7448170067921542 +2 4.5 -0.7930550483170089 -3.5453652812375784 +2 5 1.0671926518731158 -3.4778844858991573 +2.5 0.0 6.1322894796636858 0.0 +2.5 0.5 5.3815903118166384 2.9006225419880627 +2.5 1 3.3132901461132245 5.0910715229496981 +2.5 1.5 0.43378099760770306 6.0350486377665726 +2.5 2 -2.5519328677533646 5.5014353663786881 +2.5 2.5 -4.9128445653181902 3.6208788480352467 +2.5 3 -6.070920571848899 0.85380490512817953 +2.5 3.5 -5.7426234916340562 -2.1223102560413381 +2.5 4 -4.0083318996712061 -4.57880984837412 +2.5 4.5 -1.292660863206667 -5.9142570982487204 +2.5 5 1.7394986356945519 -5.8016879435447484 +3 0.0 10.067661995777767 0.0 +3 0.5 8.8352046065009961 4.8028250827430332 +3 1 5.4395809910197652 8.429751080849945 +3 1.5 0.71215823691760027 9.992780016517834 +3 2 -4.1896256909688079 9.109227893755337 +3 2.5 -8.065643131401858 5.9954190871722712 +3 3 -9.9669098341294546 1.4137225904988271 +3 3.5 -9.4279294013294948 -3.5141025016277618 +3 4 -6.5806630405511575 -7.5815527427465446 +3 4.5 -2.1222208587988538 -9.7927744565452279 +3 5 2.855815004227388 -9.606383448432581 +3.5 0.0 16.572824671057315 0.0 +3.5 0.5 14.544021932586453 7.9309579973029942 +3.5 1 8.9543353845206628 13.920140875036202 +3.5 1.5 1.1723152409600635 16.501187784675338 +3.5 2 -6.8967285595109376 15.042168425582808 +3.5 2.5 -13.27721267679628 9.9003016219435338 +3.5 3 -16.406972071821489 2.3344956961624299 +3.5 3.5 -15.519732490509515 -5.8028761944229847 +3.5 4 -10.832721125927701 -12.51950161023119 +3.5 4.5 -3.493481825361676 -16.170916398971684 +3.5 5 4.7010836654909927 -15.863126872818031 +4 0.0 27.308232836016487 0.0 +4 0.5 23.965228932930149 13.083483250697073 +4 1 14.754701170483758 22.963673499193039 +4 1.5 1.9317079733098848 27.221555588974699 +4 2 -11.36423470640106 24.814651485634183 +4 2.5 -21.877816388443744 16.332255257384478 +4 3 -27.034945603074224 3.851153334811777 +4 3.5 -25.572977257381748 -9.5728452377909345 +4 4 -17.849852190320398 -20.653077431533024 +4 4.5 -5.7564607717099641 -26.676715968779042 +4 5 7.7463130074030753 -26.168964053872834 +4.5 0.0 45.014120148530026 0.0 +4.5 0.5 39.503606881188027 21.575592860354615 +4.5 1 24.321232912876262 37.868728113387277 +4.5 1.5 3.1841728948407773 44.890278006198159 +4.5 2 -18.732483699763755 40.921122239913586 +4.5 2.5 -36.062774966457418 26.933048575266785 +4.5 3 -44.563641188115653 6.3508252964873746 +4.5 3.5 -42.153773835602316 -15.786301507647636 +4.5 4 -29.423192483874836 -34.058391136197905 +4.5 4.5 -9.4887874423825558 -43.991798786690204 +4.5 5 12.768803698036276 -43.154479826580854 +5 0.0 74.209948524787848 0.0 +5 0.5 65.125356744136013 35.574914197417463 +5 1 40.095806306298833 62.439848680799628 +5 1.5 5.2494040945477698 74.017330541269217 +5 2 -30.882235318916742 67.472788440587522 +5 2.5 -59.452826470700373 44.408554533886615 +5 3 -73.467292212645262 10.471557674805572 +5 3.5 -69.494402559543346 -26.029241711409281 +5 4 -48.506859457844584 -56.157174925130178 +5 4.5 -15.643145424999666 -72.535873167233817 +5 5 21.050556181654848 -71.1552598809822 diff --git a/commons-numbers-complex/src/test/resources/data/divide.txt b/commons-numbers-complex/src/test/resources/data/divide.txt new file mode 100644 index 0000000..9c7e6ec --- /dev/null +++ b/commons-numbers-complex/src/test/resources/data/divide.txt @@ -0,0 +1,17 @@ +# (a + b i) (u + v i) (a + b i).divide(u + v i) +2 3 5 4 0.53658536585365857 0.17073170731707318 +5 4 2 3 1.6923076923076923 -0.53846153846153844 +2 3 -5 4 0.04878048780487805 -0.56097560975609762 +-5 4 2 3 0.15384615384615385 1.7692307692307692 +2 3 5 -4 -0.04878048780487805 0.56097560975609762 +5 -4 2 3 -0.15384615384615385 -1.7692307692307692 +2 3 -5 -4 -0.53658536585365857 -0.17073170731707318 +-5 -4 2 3 -1.6923076923076923 0.53846153846153844 +2 3 -1 12 0.23448275862068965 -0.18620689655172415 +-1 12 2 3 2.6153846153846154 2.0769230769230771 +2 3 7 -9 -0.10000000000000001 0.29999999999999999 +7 -9 2 3 -1 -3 +2 3 0.0 5 0.59999999999999998 -0.40000000000000002 +0.0 5 2 3 1.1538461538461537 0.76923076923076927 +2 3 5 0.0 0.40000000000000002 0.59999999999999998 +5 0.0 2 3 0.76923076923076927 -1.1538461538461537 diff --git a/commons-numbers-complex/src/test/resources/data/exp.txt b/commons-numbers-complex/src/test/resources/data/exp.txt new file mode 100644 index 0000000..2bc1e12 --- /dev/null +++ b/commons-numbers-complex/src/test/resources/data/exp.txt @@ -0,0 +1,243 @@ +# (a + b i) exp(a + b i) +0.0 0.0 1 0.0 +0.0 0.5 0.87758256189037276 0.47942553860420301 +0.0 1 0.54030230586813977 0.8414709848078965 +0.0 1.5 0.070737201667702906 0.99749498660405445 +0.0 2 -0.41614683654714241 0.90929742682568171 +0.0 2.5 -0.8011436155469337 0.59847214410395644 +0.0 3 -0.98999249660044542 0.14112000805986721 +0.0 3.5 -0.93645668729079634 -0.35078322768961984 +0.0 4 -0.65364362086361194 -0.7568024953079282 +0.0 4.5 -0.21079579943077972 -0.97753011766509701 +0.0 5 0.2836621854632263 -0.95892427466313845 +0.5 0.0 1.6487212707001282 0.0 +0.5 0.5 1.4468890365841693 0.79043908321361489 +0.5 1 0.89080790429312873 1.3873511113297634 +0.5 1.5 0.11662592901934636 1.644591201830844 +0.5 2 -0.68611014114984314 1.4991780090003948 +0.5 2.5 -1.3208625198378354 0.98671375390570526 +0.5 3 -1.6322216869786788 0.23266755900967662 +0.5 3.5 -1.5439560594257142 -0.57834376889672245 +0.5 4 -1.0776761411752871 -1.2477563717331153 +0.5 4.5 -0.34754351829576452 -1.6116746977444445 +0.5 5 0.46767987886650592 -1.5809988486278084 +1 0.0 2.7182818284590451 0.0 +1 0.5 2.3855167309591354 1.3032137296869954 +1 1 1.4686939399158851 2.2873552871788423 +1 1.5 0.19228364988935967 2.7114724960648 +1 2 -1.1312043837568135 2.4717266720048188 +1 2.5 -2.1777341321272092 1.6268159541567078 +1 3 -2.6910786138197937 0.38360395354113103 +1 3.5 -2.5455531962015261 -0.95352767355690538 +1 4 -1.7767875768817298 -2.057202470728003 +1 4.5 -0.57300239110818607 -2.6572023556204654 +1 5 0.77107376416566753 -2.6066264306850795 +1.5 0.0 4.4816890703380645 0.0 +1.5 0.5 3.9330521759433617 2.1486361964033964 +1.5 1 2.4214669388876957 3.7712113156201572 +1.5 1.5 0.31702214358044362 4.4704623791804048 +1.5 2 -1.8650407290090891 4.0751883394911834 +1.5 2.5 -3.5904765855678131 2.6821660671324885 +1.5 3 -4.4368385517309097 0.63245599772792649 +1.5 3.5 -4.196907700276153 -1.572101357594478 +1.5 4 -2.9294274715206474 -3.3917534716261164 +1.5 4.5 -0.94472123038210032 -4.3809860442659474 +1.5 5 1.2712857162587503 -4.297600441039644 +2 0.0 7.3890560989306504 0.0 +2 0.5 6.4845067812512438 3.5425022000064983 +2 1 3.9923240484412719 6.2176763123679679 +2 1.5 0.52268115140402749 7.3705464144194357 +2 2 -3.0749323206393591 6.7188496974282499 +2 2.5 -5.9196951185764224 4.4221442464314427 +2 3 -7.3151100949011028 1.0427436562359045 +2 3.5 -6.9195309966104519 -2.5919569479625646 +2 4 -4.8298093832693851 -5.5920560936409816 +2 4.5 -1.5575819874129651 -7.2230248778216817 +2 5 2.0959958015330495 -7.0855452601123137 +2.5 0.0 12.182493960703473 0.0 +2.5 0.5 10.691144260248148 5.8405987286527132 +2.5 1 6.5822295781927735 10.251215190529404 +2.5 1.5 0.86175553211385436 12.151976650135886 +2.5 2 -5.0697063230014177 11.077510410787076 +2.5 2.5 -9.7599272580566652 7.2908832811957085 +2.5 3 -12.060577610976679 1.7191936459237578 +2.5 3.5 -11.408377937380507 -4.2734145528448648 +2.5 4 -7.9630094636233029 -9.2197418285341541 +2.5 4.5 -2.5680185535071347 -11.9087547548608 +2.5 5 3.4557128612857029 -11.682089184855643 +3 0.0 20.085536923187668 0.0 +3 0.5 17.626716949994709 9.6295193575538534 +3 1 10.852261914197959 16.901396535150095 +3 1.5 1.4207946759396191 20.035222384130325 +3 2 -8.3585326509353717 18.263727040666765 +3 2.5 -16.091399670844002 12.020634347899307 +3 3 -19.884530844146987 2.8344711324870042 +3 3.5 -18.809235369545299 -7.0456694717948061 +3 4 -13.128783081462158 -15.200784463067954 +3 4.5 -4.2339468127197879 -19.634217271890293 +3 5 5.6975072998337399 -19.260508925287422 +3.5 0.0 33.115451958692312 0.0 +3.5 0.5 29.061543168066763 15.87639339141767 +3.5 1 17.89235505314706 27.865691972039404 +3.5 1.5 2.3424944035191451 33.032497307922995 +3.5 2 -13.780890573438676 30.111795254208399 +3.5 2.5 -26.530232912657546 19.818675536690151 +3.5 3 -32.784048960637911 4.6732528473168049 +3.5 3.5 -31.011186439374516 -11.616345124470632 +3.5 4 -21.645703924814633 -25.06185667558816 +3.5 4.5 -6.9805981691441259 -32.371351649713361 +3.5 5 9.3936014752051396 -31.755210749631033 +4 0.0 54.598150033144236 0.0 +4 0.5 47.914384380561657 26.175747486433259 +4 1 29.499506359042481 45.942759077079167 +4 1.5 3.8621203495780239 54.461380935917362 +4 2 -22.720847417619233 49.645957334580565 +4 2.5 -43.740959319727111 32.675471914445332 +4 3 -54.051758861078156 7.7048913727311543 +4 3.5 -51.128802712244131 -19.152115294508459 +4 4 -35.687732480119131 -41.320016184280199 +4 4.5 -11.509060683678292 -53.371336026196104 +4 5 15.487430560650816 -52.355491418482046 +4.5 0.0 90.017131300521811 0.0 +4.5 0.5 78.997464700734 43.156511657357932 +4.5 1 48.636463609307036 75.746804125031815 +4.5 1.5 6.3675599703531027 89.791637180749419 +4.5 2 -37.460344425760908 81.852345861794021 +4.5 2.5 -72.116650031263092 53.872745575510656 +4.5 3 -89.116284553013685 12.703218294655763 +4.5 3.5 -84.297144577107304 -31.576499864957349 +4.5 4 -58.839123643028252 -68.125189588696315 +4.5 4.5 -18.975233154958961 -87.994456952073577 +4.5 5 25.53445619383621 -86.319612339609378 +5 0.0 148.4131591025766 0.0 +5 0.5 130.24480038348267 71.153058738704061 +5 1 80.187972084297229 124.88536714849616 +5 1.5 10.498331565579837 148.04138215089006 +5 2 -61.761666662504986 134.95170367904339 +5 2.5 -118.90025487818053 88.821141541360632 +5 3 -146.92791390831894 20.944066208745966 +5 3.5 -138.98249532356078 -52.060846981614901 +5 4 -97.009314699615501 -112.31944914536253 +5 4.5 -31.284870519075138 -145.07833288059047 +5 5 42.099201062538398 -142.31698094290323 +-0.0 -0.0 1 0.0 +-0.0 -0.5 0.87758256189037276 -0.47942553860420301 +-0.0 -1 0.54030230586813977 -0.8414709848078965 +-0.0 -1.5 0.070737201667702906 -0.99749498660405445 +-0.0 -2 -0.41614683654714241 -0.90929742682568171 +-0.0 -2.5 -0.8011436155469337 -0.59847214410395644 +-0.0 -3 -0.98999249660044542 -0.14112000805986721 +-0.0 -3.5 -0.93645668729079634 0.35078322768961984 +-0.0 -4 -0.65364362086361194 0.7568024953079282 +-0.0 -4.5 -0.21079579943077972 0.97753011766509701 +-0.0 -5 0.2836621854632263 0.95892427466313845 +-0.5 -0.0 0.60653065971263342 0.0 +-0.5 -0.5 0.53228073021567079 -0.29078628821269187 +-0.5 -1 0.32770991402245986 -0.51037795154457277 +-0.5 -1.5 0.042904281593737437 -0.60501129228500161 +-0.5 -2 -0.25240581530826373 -0.55151676816758077 +-0.5 -2.5 -0.48591816566224605 -0.36299170438300693 +-0.5 -3 -0.60046080207362518 -0.085593611587203411 +-0.5 -3.5 -0.56798969233479402 0.21276078250671202 +-0.5 -4 -0.396454896579361 0.45902391675128484 +-0.5 -4.5 -0.12785411529340279 0.59290198715637943 +-0.5 -5 0.17204981248453802 0.58161697292589187 +-1 -0.0 0.36787944117144233 0.0 +-1 -0.5 0.32284458245003306 -0.17637079922503196 +-1 -1 0.19876611034641298 -0.30955987565311222 +-1 -1.5 0.026022762219546164 -0.3669578982432149 +-1 -2 -0.15309186567422631 -0.33451182923926226 +-1 -2.5 -0.29472426558547482 -0.22016559792963841 +-1 -3 -0.36419788641329287 -0.051915149703173388 +-1 -3.5 -0.34450316280179827 0.12904593777477216 +-1 -4 -0.2404620499685837 0.27841207905103371 +-1 -4.5 -0.077547440895882683 0.35961323341489015 +-1 -5 0.10435348626968173 0.35276852628880606 +-1.5 -0.0 0.22313016014842982 0.0 +-1.5 -0.5 0.1958151375780682 -0.10697429720800304 +-1.5 -1 0.12055774003692393 -0.18775755560044291 +-1.5 -1.5 0.015783603136566328 -0.22257121610821853 +-1.5 -2 -0.092854910284026329 -0.20289168047016951 +-1.5 -2.5 -0.1787593032388794 -0.13353718535828996 +-1.5 -3 -0.22089718431220126 -0.031488129998545882 +-1.5 -3.5 -0.20895173060726344 0.078270317771767989 +-1.5 -4 -0.14584760580329728 0.16886546197878932 +-1.5 -4.5 -0.047034900485606171 0.21811645170452654 +-1.5 -5 0.063293588870463283 0.21396492697580299 +-2 -0.0 0.1353352832366127 0.0 +-2 -0.5 0.11876788457694579 -0.064883191057865414 +-2 -1 0.073121965598059641 -0.1138807140643681 +-2 -1.5 0.0095732392230639656 -0.13499626653916091 +-2 -2 -0.056319349992127891 -0.12306002480577674 +-2 -2.5 -0.10842299812324822 -0.080994397131531837 +-2 -3 -0.13398091492954262 -0.019098516261135196 +-2 -3.5 -0.12673563101331997 0.047473347474027906 +-2 -4 -0.088461044565382008 0.10242208005667372 +-2 -4.5 -0.028528109221052776 0.13229431534652525 +-2 -5 0.038389502213182297 0.12977628831399923 +-2.5 -0.0 0.0820849986238988 0.0 +-2.5 -0.5 0.072036363385128838 -0.039353644676587946 +-2.5 -1 0.044350714033675603 -0.069072144630006951 +-2.5 -1.5 0.0058064631015518446 -0.081879374602739766 +-2.5 -2 -0.034159412505312022 -0.074639678029700798 +-2.5 -2.5 -0.065761872579715358 -0.049125585125215025 +-2.5 -3 -0.081263532721117693 -0.011583835667398788 +-2.5 -3.5 -0.076869045887605847 0.028794040762189225 +-2.5 -4 -0.053654335719109818 0.062122131785914463 +-2.5 -4.5 -0.017303172906199201 0.080240558363359124 +-2.5 -5 0.023284410103401057 0.07871329776614687 +-3 -0.0 0.049787068367863944 0.0 +-3 -0.5 0.043692263007281178 -0.02386919206778745 +-3 -1 0.026900067841571611 -0.041894373450204546 +-3 -1.5 0.0035217978955813041 -0.049662351094657588 +-3 -2 -0.02071873100224288 -0.045271253156092976 +-3 -2.5 -0.039886591959712898 -0.029796173554765801 +-3 -3 -0.049288824111918692 -0.0070259514893501202 +-3 -3.5 -0.046623433113690264 0.017464468539283087 +-3 -4 -0.032542999640154786 0.037678977574865852 +-3 -4.5 -0.010494904877918765 0.048668358799838274 +-3 -5 0.014122708621035349 0.047742028422258019 +-3.5 -0.0 0.030197383422318501 0.0 +-3.5 -0.5 0.026500697106144142 -0.014477396811682678 +-3.5 -1 0.016315715894263023 -0.025410221966999998 +-3.5 -1.5 0.0021360784009814924 -0.03012173857232309 +-3.5 -2 -0.012566545583198965 -0.027458403042782711 +-3.5 -2.5 -0.024192440935013281 -0.018072292803084224 +-3.5 -3 -0.029895183005061995 -0.0042614549919444871 +-3.5 -3.5 -0.028278541644514394 0.010592735624661903 +-3.5 -4 -0.019738327040771074 0.022853455125780905 +-3.5 -4.5 -0.006365481579225403 0.029518851769997054 +-3.5 -5 0.0085658557768458661 0.028957003994971451 +-4 -0.0 0.018315638888734179 0.0 +-4 -0.5 0.016073485298634279 -0.0087809850391114691 +-4 -1 0.0098959819250312494 -0.015412078693088957 +-4 -1.5 0.0012955970417452116 -0.018269757967962597 +-4 -2 -0.0076219951828865474 -0.016654363312194376 +-4 -2.5 -0.014673457160372523 -0.01096139967637455 +-4 -3 -0.018132345070290157 -0.0025847031075997848 +-4 -3.5 -0.017151802519358491 0.0064248189265876969 +-4 -4 -0.01197190052166259 0.013861321214152955 +-4 -4.5 -0.003860859741636199 0.01790408863801575 +-4 -5 0.0051954541553335945 0.017563310736371393 +-4.5 -0.0 0.011108996538242306 0.0 +-4.5 -0.5 0.0097490616420619659 -0.005325936648699044 +-4.5 -1 0.0060022164454935001 -0.0093478982572622656 +-4.5 -1.5 0.00078581932845145949 -0.011081168353098496 +-4.5 -2 -0.0046229737666026918 -0.010101381966839134 +-4.5 -2.5 -0.0088999016517458118 -0.0066484249770853024 +-4.5 -3 -0.010997823217620207 -0.0015677016810137913 +-4.5 -3.5 -0.010403094097327314 0.0038968496620774493 +-4.5 -4 -0.0072613247214180316 0.0084073163005089126 +-4.5 -4.5 -0.0023417298061525513 0.010859378693169157 +-4.5 -5 0.0031512022363412279 0.01065268644766932 +-5 -0.0 0.006737946999085467 0.0 +-5 -0.5 0.0059131047893389733 -0.0032303438691231234 +-5 -1 0.0036405283004231903 -0.0056697868969038589 +-5 -1.5 0.00047662351570060231 -0.0067210683515915868 +-5 -2 -0.0028039753284917284 -0.0061267978683562391 +-5 -2.5 -0.0053980632202109431 -0.0040324735874014981 +-5 -3 -0.0066705169715861002 -0.00095085913481789922 +-5 -3.5 -0.0063097955259045387 0.002363558796340788 +-5 -4 -0.0044042160736693326 0.0050992951021604479 +-5 -4.5 -0.0014203309241944443 0.0065865461228372035 +-5 -5 0.0019113007712959708 0.0064611809388167019 diff --git a/commons-numbers-complex/src/test/resources/data/log.txt b/commons-numbers-complex/src/test/resources/data/log.txt new file mode 100644 index 0000000..ec54dbb --- /dev/null +++ b/commons-numbers-complex/src/test/resources/data/log.txt @@ -0,0 +1,243 @@ +# (a + b i) log(a + b i) +0.0 0.0 -Infinity 0.0 +0.0 0.5 -0.69314718055994529 1.5707963267948966 +0.0 1 0.0 1.5707963267948966 +0.0 1.5 0.40546510810816438 1.5707963267948966 +0.0 2 0.69314718055994529 1.5707963267948966 +0.0 2.5 0.91629073187415511 1.5707963267948966 +0.0 3 1.0986122886681098 1.5707963267948966 +0.0 3.5 1.2527629684953681 1.5707963267948966 +0.0 4 1.3862943611198906 1.5707963267948966 +0.0 4.5 1.5040773967762742 1.5707963267948966 +0.0 5 1.6094379124341003 1.5707963267948966 +0.5 0.0 -0.69314718055994529 0.0 +0.5 0.5 -0.34657359027997264 0.78539816339744828 +0.5 1 0.11157177565710488 1.1071487177940904 +0.5 1.5 0.45814536593707755 1.2490457723982544 +0.5 2 0.72345949146816269 1.3258176636680326 +0.5 2.5 0.93590108845079578 1.3734007669450159 +0.5 3 1.112311775762167 1.4056476493802699 +0.5 3.5 1.2628643221541278 1.4288992721907328 +0.5 4 1.3940464543878732 1.4464413322481351 +0.5 4.5 1.5102124430721813 1.4601391056210009 +0.5 5 1.6144130778606842 1.4711276743037347 +1 0.0 0.0 0.0 +1 0.5 0.11157177565710488 0.46364760900080609 +1 1 0.34657359027997264 0.78539816339744828 +1 1.5 0.58932749817082308 0.98279372324732905 +1 2 0.80471895621705014 1.1071487177940904 +1 2.5 0.99050073443329179 1.1902899496825317 +1 3 1.151292546497023 1.2490457723982544 +1 3.5 1.2919987762161156 1.2924966677897853 +1 4 1.4166066720281081 1.3258176636680326 +1 4.5 1.5281784476852129 1.3521273809209546 +1 5 1.6290482690107408 1.3734007669450159 +1.5 0.0 0.40546510810816438 0.0 +1.5 0.5 0.45814536593707755 0.32175055439664219 +1.5 1 0.58932749817082308 0.5880026035475675 +1.5 1.5 0.75203869838813708 0.78539816339744828 +1.5 2 0.91629073187415511 0.92729521800161219 +1.5 2.5 1.0700330817481354 1.0303768265243125 +1.5 3 1.2101840643252146 1.1071487177940904 +1.5 3.5 1.3370743247132644 1.1659045405098132 +1.5 4 1.4520825400142503 1.2120256565243244 +1.5 4.5 1.5567576546051873 1.2490457723982544 +1.5 5 1.6525267605546266 1.2793395323170296 +2 0.0 0.69314718055994529 0.0 +2 0.5 0.72345949146816269 0.24497866312686414 +2 1 0.80471895621705014 0.46364760900080609 +2 1.5 0.91629073187415511 0.64350110879328437 +2 2 1.0397207708399179 0.78539816339744828 +2 2.5 1.1636388527922086 0.89605538457134393 +2 3 1.2824746787307684 0.98279372324732905 +2 3.5 1.3940464543878732 1.0516502125483738 +2 4 1.4978661367769954 1.1071487177940904 +2 4.5 1.5942083086917462 1.1525719972156676 +2 5 1.6836479149932368 1.1902899496825317 +2.5 0.0 0.91629073187415511 0.0 +2.5 0.5 0.93590108845079578 0.19739555984988075 +2.5 1 0.99050073443329179 0.3805063771123649 +2.5 1.5 1.0700330817481354 0.54041950027058416 +2.5 2 1.1636388527922086 0.67474094222355263 +2.5 2.5 1.2628643221541278 0.78539816339744828 +2.5 3 1.3622897515267105 0.87605805059819342 +2.5 3.5 1.4588853660421397 0.95054684081207519 +2.5 4 1.5511710043061246 1.0121970114513341 +2.5 4.5 1.6385723664960883 1.0636978224025597 +2.5 5 1.7210096880912051 1.1071487177940904 +3 0.0 1.0986122886681098 0.0 +3 0.5 1.112311775762167 0.16514867741462683 +3 1 1.151292546497023 0.32175055439664219 +3 1.5 1.2101840643252146 0.46364760900080609 +3 2 1.2824746787307684 0.5880026035475675 +3 2.5 1.3622897515267105 0.69473827619670314 +3 3 1.4451858789480825 0.78539816339744828 +3 3.5 1.5281784476852129 0.8621700546672264 +3 4 1.6094379124341003 0.92729521800161219 +3 4.5 1.6879397868389328 0.98279372324732905 +3 5 1.7631802623080806 1.0303768265243125 +3.5 0.0 1.2527629684953681 0.0 +3.5 0.5 1.2628643221541278 0.14189705460416394 +3.5 1 1.2919987762161156 0.27829965900511133 +3.5 1.5 1.3370743247132644 0.40489178628508343 +3.5 2 1.3940464543878732 0.51914611424652291 +3.5 2.5 1.4588853660421397 0.62024948598282148 +3.5 3 1.5281784476852129 0.70862627212767026 +3.5 3.5 1.5993365587753408 0.78539816339744828 +3.5 4 1.670546728796225 0.85196632717327214 +3.5 4.5 1.7406200446678459 0.90975315794420974 +3.5 5 1.8088259724127842 0.96007036240568799 +4 0.0 1.3862943611198906 0.0 +4 0.5 1.3940464543878732 0.12435499454676144 +4 1 1.4166066720281081 0.24497866312686414 +4 1.5 1.4520825400142503 0.35877067027057225 +4 2 1.4978661367769954 0.46364760900080609 +4 2.5 1.5511710043061246 0.55859931534356244 +4 3 1.6094379124341003 0.64350110879328437 +4 3.5 1.670546728796225 0.71882999962162453 +4 4 1.7328679513998633 0.78539816339744828 +4 4.5 1.7952196906503419 0.84415398611317105 +4 5 1.8567860333521538 0.89605538457134393 +4.5 0.0 1.5040773967762742 0.0 +4.5 0.5 1.5102124430721813 0.11065722117389565 +4.5 1 1.5281784476852129 0.21866894587394195 +4.5 1.5 1.5567576546051873 0.32175055439664219 +4.5 2 1.5942083086917462 0.41822432957922911 +4.5 2.5 1.6385723664960883 0.50709850439233695 +4.5 3 1.6879397868389328 0.5880026035475675 +4.5 3.5 1.7406200446678459 0.66104316885068692 +4.5 4 1.7952196906503419 0.72664234068172562 +4.5 4.5 1.8506509870562469 0.78539816339744828 +4.5 5 1.9061013350729674 0.83798122500839001 +5 0.0 1.6094379124341003 0.0 +5 0.5 1.6144130778606842 0.099668652491162024 +5 1 1.6290482690107408 0.19739555984988075 +5 1.5 1.6525267605546266 0.2914567944778671 +5 2 1.6836479149932368 0.3805063771123649 +5 2.5 1.7210096880912051 0.46364760900080609 +5 3 1.7631802623080806 0.54041950027058416 +5 3.5 1.8088259724127842 0.61072596438920856 +5 4 1.8567860333521538 0.67474094222355263 +5 4.5 1.9061013350729674 0.73281510178650655 +5 5 1.956011502714073 0.78539816339744828 +-0.0 -0.0 -Infinity -3.1415926535897931 +-0.0 -0.5 -0.69314718055994529 -1.5707963267948966 +-0.0 -1 0.0 -1.5707963267948966 +-0.0 -1.5 0.40546510810816438 -1.5707963267948966 +-0.0 -2 0.69314718055994529 -1.5707963267948966 +-0.0 -2.5 0.91629073187415511 -1.5707963267948966 +-0.0 -3 1.0986122886681098 -1.5707963267948966 +-0.0 -3.5 1.2527629684953681 -1.5707963267948966 +-0.0 -4 1.3862943611198906 -1.5707963267948966 +-0.0 -4.5 1.5040773967762742 -1.5707963267948966 +-0.0 -5 1.6094379124341003 -1.5707963267948966 +-0.5 -0.0 -0.69314718055994529 -3.1415926535897931 +-0.5 -0.5 -0.34657359027997264 -2.3561944901923448 +-0.5 -1 0.11157177565710488 -2.0344439357957027 +-0.5 -1.5 0.45814536593707755 -1.8925468811915389 +-0.5 -2 0.72345949146816269 -1.8157749899217608 +-0.5 -2.5 0.93590108845079578 -1.7681918866447774 +-0.5 -3 1.112311775762167 -1.7359450042095235 +-0.5 -3.5 1.2628643221541278 -1.7126933813990606 +-0.5 -4 1.3940464543878732 -1.695151321341658 +-0.5 -4.5 1.5102124430721813 -1.6814535479687922 +-0.5 -5 1.6144130778606842 -1.6704649792860586 +-1 -0.0 0.0 -3.1415926535897931 +-1 -0.5 0.11157177565710488 -2.677945044588987 +-1 -1 0.34657359027997264 -2.3561944901923448 +-1 -1.5 0.58932749817082308 -2.158798930342464 +-1 -2 0.80471895621705014 -2.0344439357957027 +-1 -2.5 0.99050073443329179 -1.9513027039072615 +-1 -3 1.151292546497023 -1.8925468811915389 +-1 -3.5 1.2919987762161156 -1.849095985800008 +-1 -4 1.4166066720281081 -1.8157749899217608 +-1 -4.5 1.5281784476852129 -1.7894652726688385 +-1 -5 1.6290482690107408 -1.7681918866447774 +-1.5 -0.0 0.40546510810816438 -3.1415926535897931 +-1.5 -0.5 0.45814536593707755 -2.819842099193151 +-1.5 -1 0.58932749817082308 -2.5535900500422257 +-1.5 -1.5 0.75203869838813708 -2.3561944901923448 +-1.5 -2 0.91629073187415511 -2.2142974355881808 +-1.5 -2.5 1.0700330817481354 -2.1112158270654806 +-1.5 -3 1.2101840643252146 -2.0344439357957027 +-1.5 -3.5 1.3370743247132644 -1.9756881130799799 +-1.5 -4 1.4520825400142503 -1.9295669970654687 +-1.5 -4.5 1.5567576546051873 -1.8925468811915389 +-1.5 -5 1.6525267605546266 -1.8622531212727638 +-2 -0.0 0.69314718055994529 -3.1415926535897931 +-2 -0.5 0.72345949146816269 -2.8966139904629289 +-2 -1 0.80471895621705014 -2.677945044588987 +-2 -1.5 0.91629073187415511 -2.4980915447965089 +-2 -2 1.0397207708399179 -2.3561944901923448 +-2 -2.5 1.1636388527922086 -2.2455372690184494 +-2 -3 1.2824746787307684 -2.158798930342464 +-2 -3.5 1.3940464543878732 -2.0899424410414196 +-2 -4 1.4978661367769954 -2.0344439357957027 +-2 -4.5 1.5942083086917462 -1.9890206563741257 +-2 -5 1.6836479149932368 -1.9513027039072615 +-2.5 -0.0 0.91629073187415511 -3.1415926535897931 +-2.5 -0.5 0.93590108845079578 -2.9441970937399127 +-2.5 -1 0.99050073443329179 -2.7610862764774282 +-2.5 -1.5 1.0700330817481354 -2.6011731533192091 +-2.5 -2 1.1636388527922086 -2.4668517113662407 +-2.5 -2.5 1.2628643221541278 -2.3561944901923448 +-2.5 -3 1.3622897515267105 -2.2655346029915999 +-2.5 -3.5 1.4588853660421397 -2.1910458127777179 +-2.5 -4 1.5511710043061246 -2.129395642138459 +-2.5 -4.5 1.6385723664960883 -2.0778948311872334 +-2.5 -5 1.7210096880912051 -2.0344439357957027 +-3 -0.0 1.0986122886681098 -3.1415926535897931 +-3 -0.5 1.112311775762167 -2.9764439761751662 +-3 -1 1.151292546497023 -2.819842099193151 +-3 -1.5 1.2101840643252146 -2.677945044588987 +-3 -2 1.2824746787307684 -2.5535900500422257 +-3 -2.5 1.3622897515267105 -2.4468543773930902 +-3 -3 1.4451858789480825 -2.3561944901923448 +-3 -3.5 1.5281784476852129 -2.2794225989225669 +-3 -4 1.6094379124341003 -2.2142974355881808 +-3 -4.5 1.6879397868389328 -2.158798930342464 +-3 -5 1.7631802623080806 -2.1112158270654806 +-3.5 -0.0 1.2527629684953681 -3.1415926535897931 +-3.5 -0.5 1.2628643221541278 -2.9996955989856291 +-3.5 -1 1.2919987762161156 -2.8632929945846817 +-3.5 -1.5 1.3370743247132644 -2.7367008673047097 +-3.5 -2 1.3940464543878732 -2.6224465393432701 +-3.5 -2.5 1.4588853660421397 -2.5213431676069717 +-3.5 -3 1.5281784476852129 -2.4329663814621232 +-3.5 -3.5 1.5993365587753408 -2.3561944901923448 +-3.5 -4 1.670546728796225 -2.2896263264165211 +-3.5 -4.5 1.7406200446678459 -2.2318394956455836 +-3.5 -5 1.8088259724127842 -2.1815222911841055 +-4 -0.0 1.3862943611198906 -3.1415926535897931 +-4 -0.5 1.3940464543878732 -3.0172376590430319 +-4 -1 1.4166066720281081 -2.8966139904629289 +-4 -1.5 1.4520825400142503 -2.7828219833192209 +-4 -2 1.4978661367769954 -2.677945044588987 +-4 -2.5 1.5511710043061246 -2.5829933382462307 +-4 -3 1.6094379124341003 -2.4980915447965089 +-4 -3.5 1.670546728796225 -2.4227626539681686 +-4 -4 1.7328679513998633 -2.3561944901923448 +-4 -4.5 1.7952196906503419 -2.2974386674766221 +-4 -5 1.8567860333521538 -2.2455372690184494 +-4.5 -0.0 1.5040773967762742 -3.1415926535897931 +-4.5 -0.5 1.5102124430721813 -3.0309354324158977 +-4.5 -1 1.5281784476852129 -2.9229237077158512 +-4.5 -1.5 1.5567576546051873 -2.819842099193151 +-4.5 -2 1.5942083086917462 -2.7233683240105639 +-4.5 -2.5 1.6385723664960883 -2.6344941491974563 +-4.5 -3 1.6879397868389328 -2.5535900500422257 +-4.5 -3.5 1.7406200446678459 -2.4805494847391065 +-4.5 -4 1.7952196906503419 -2.4149503129080676 +-4.5 -4.5 1.8506509870562469 -2.3561944901923448 +-4.5 -5 1.9061013350729674 -2.3036114285814033 +-5 -0.0 1.6094379124341003 -3.1415926535897931 +-5 -0.5 1.6144130778606842 -3.0419240010986313 +-5 -1 1.6290482690107408 -2.9441970937399127 +-5 -1.5 1.6525267605546266 -2.8501358591119264 +-5 -2 1.6836479149932368 -2.7610862764774282 +-5 -2.5 1.7210096880912051 -2.677945044588987 +-5 -3 1.7631802623080806 -2.6011731533192091 +-5 -3.5 1.8088259724127842 -2.5308666892005847 +-5 -4 1.8567860333521538 -2.4668517113662407 +-5 -4.5 1.9061013350729674 -2.4087775518032868 +-5 -5 1.956011502714073 -2.3561944901923448 diff --git a/commons-numbers-complex/src/test/resources/data/multiply.txt b/commons-numbers-complex/src/test/resources/data/multiply.txt new file mode 100644 index 0000000..50ebe14 --- /dev/null +++ b/commons-numbers-complex/src/test/resources/data/multiply.txt @@ -0,0 +1,17 @@ +# (a + b i) (u + v i) (a + b i).multiply(u + v i) +2 3 5 4 -2 23 +5 4 2 3 -2 23 +2 3 -5 4 -22 -7 +-5 4 2 3 -22 -7 +2 3 5 -4 22 7 +5 -4 2 3 22 7 +2 3 -5 -4 2 -23 +-5 -4 2 3 2 -23 +2 3 -1 12 -38 21 +-1 12 2 3 -38 21 +2 3 7 -9 41 3 +7 -9 2 3 41 3 +2 3 0.0 5 -15 10 +0.0 5 2 3 -15 10 +2 3 5 0.0 10 15 +5 0.0 2 3 10 15 diff --git a/commons-numbers-complex/src/test/resources/data/pow.txt b/commons-numbers-complex/src/test/resources/data/pow.txt new file mode 100644 index 0000000..6714b3b --- /dev/null +++ b/commons-numbers-complex/src/test/resources/data/pow.txt @@ -0,0 +1,17 @@ +# (a + b i) (u + v i) (a + b i).pow(u + v i) +2 3 5 4 -9.7367145095888414 -6.9377513609299886 +5 4 2 3 4.3549103166315373 3.2198331430252147 +2 3 -5 4 3.1452105198427317e-05 6.8990150088148226e-06 +-5 4 2 3 -0.011821399482548249 -0.02208233453952109 +2 3 5 -4 30334.832969842264 -6653.9414970320349 +5 -4 2 3 -146.48661898442663 -273.63651239033993 +2 3 -5 -4 -0.068119398044204305 0.048537465694561743 +-5 -4 2 3 53964.514878760994 39899.038308625939 +2 3 -1 12 -5.5824460482771003e-07 2.0191622518316361e-06 +-1 12 2 3 -0.22408355253971604 -0.98998910763799719 +2 3 7 -9 -2729857.3750238167 54911428.403424568 +7 -9 2 3 1385.7129369399429 -1430.757158200254 +2 3 0.0 5 0.0072820947869755249 0.00094602869084606884 +0.0 5 2 3 -0.025976373555576252 0.22307493471553799 +2 3 5 0.0 122 -597 +5 0.0 2 3 2.8916321974293986 -24.83220616930339 diff --git a/commons-numbers-complex/src/test/resources/data/sinh.txt b/commons-numbers-complex/src/test/resources/data/sinh.txt new file mode 100644 index 0000000..895b85c --- /dev/null +++ b/commons-numbers-complex/src/test/resources/data/sinh.txt @@ -0,0 +1,122 @@ +# (a + b i) sinh(a + b i) +0.0 0.0 0.0 0.0 +0.0 0.5 0.0 0.47942553860420301 +0.0 1 0.0 0.8414709848078965 +0.0 1.5 0.0 0.99749498660405445 +0.0 2 0.0 0.90929742682568171 +0.0 2.5 0.0 0.59847214410395644 +0.0 3 0.0 0.14112000805986721 +0.0 3.5 0.0 -0.35078322768961984 +0.0 4 0.0 -0.7568024953079282 +0.0 4.5 0.0 -0.97753011766509701 +0.0 5 0.0 -0.95892427466313845 +0.5 0.0 0.52109530549374738 0.0 +0.5 0.5 0.45730415318424927 0.54061268571315335 +0.5 1 0.28154899513533443 0.94886453143716798 +0.5 1.5 0.036860823712804462 1.1248012470579227 +0.5 2 -0.21685216292078974 1.0253473885839877 +0.5 2.5 -0.41747217708779472 0.67485272914435601 +0.5 3 -0.51588044245252673 0.15913058529843999 +0.5 3.5 -0.48798318354546016 -0.39555227570171719 +0.5 4 -0.34061062229796307 -0.85339014424219994 +0.5 4.5 -0.10984470150118086 -1.102288342450412 +0.5 5 0.14781503319098394 -1.08130791077685 +1 0.0 1.1752011936438014 0.0 +1 0.5 1.0313360742545512 0.73979226445601376 +1 1 0.63496391478473613 1.2984575814159773 +1 1.5 0.083130443834906753 1.5392151971540073 +1 2 -0.48905625904129368 1.4031192506220405 +1 2.5 -0.94150493327086715 0.92349077604317309 +1 3 -1.1634403637032504 0.21775955162215221 +1 3.5 -1.1005250166998639 -0.54128680566583875 +1 4 -0.76816276345657308 -1.1678072748895183 +1 4.5 -0.24772747510615167 -1.5084077945176777 +1 5 0.33336013894799293 -1.4796974784869428 +1.5 0.0 2.1292794550948173 0.0 +1.5 0.5 1.8686185191826468 1.1278052468056998 +1.5 1 1.1504545994253859 1.9794844356103001 +1.5 1.5 0.15061927022193863 2.3465167976443118 +1.5 2 -0.88609290936253138 2.1390400099806768 +1.5 2.5 -1.7058586411644667 1.4078516262453893 +1.5 3 -2.1079706837093544 0.33197206386323619 +1.5 3.5 -1.9939779848344446 -0.82518583768312304 +1.5 4 -1.3917899328586749 -1.7803094668024528 +1.5 4.5 -0.44884316494824705 -2.2995512479852369 +1.5 5 0.60399606369414349 -2.2557826840077233 +2 0.0 3.626860407847019 0.0 +2 0.5 3.1828694483371494 1.8036926955321817 +2 1 1.9596010414216063 3.1657785132161682 +2 1.5 0.25655395609048182 3.7527713404792982 +2 2 -1.5093064853236158 3.4209548611170133 +2 2.5 -2.9056360602265872 2.2515693217814872 +2 3 -3.5905645899857799 0.53092108624851975 +2 3.5 -3.396397682798566 -1.3197151477182962 +2 4 -2.3706741693520019 -2.8472390868488278 +2 4.5 -0.76452693909595615 -3.6776595965841032 +2 5 1.0288031496599337 -3.6076607742131563 +2.5 0.0 6.0502044810397875 0.0 +2.5 0.5 5.3095539484315095 2.9399761866646505 +2.5 1 3.2689394320795491 5.160143667579705 +2.5 1.5 0.42797453450615125 6.1169280123693124 +2.5 2 -2.5177734552480531 5.5760750444083884 +2.5 2.5 -4.8470826927384749 3.6700044331604613 +2.5 3 -5.9896570391277812 0.86538874079557826 +2.5 3.5 -5.665754445746451 -2.1511042968035272 +2.5 4 -3.9546775639520968 -4.6409319801600342 +2.5 4.5 -1.2753576903004678 -5.9944976566120793 +2.5 5 1.716214225591151 -5.8804012413108948 +3 0.0 10.017874927409903 0.0 +3 0.5 8.7915123434937144 4.826694274810821 +3 1 5.4126809231781934 8.47164545430015 +3 1.5 0.70863643902201889 10.042442367612491 +3 2 -4.1689069599665647 9.1544991469114301 +3 2.5 -8.0257565394421455 6.0252152607270375 +3 3 -9.9176210100175357 1.4207485419881773 +3 3.5 -9.3813059682158038 -3.5315669701670451 +3 4 -6.5481200409110025 -7.6192317203214106 +3 4.5 -2.111725953920935 -9.8414428153450668 +3 5 2.8416922956063524 -9.6541254768548406 +3.5 0.0 16.542627287634996 0.0 +3.5 0.5 14.517521235480308 7.9454353941146767 +3.5 1 8.9380196686263993 13.945551097003202 +3.5 1.5 1.1701791625590818 16.531309523247661 +3.5 2 -6.8841620139277389 15.069626828625593 +3.5 2.5 -13.253020235861266 9.9183739147466188 +3.5 3 -16.377076888816426 2.3387571511543745 +3.5 3.5 -15.491453948865001 -5.8134689300476472 +3.5 4 -10.81298279888693 -12.54235506535697 +3.5 4.5 -3.4871163437824504 -16.20043525074168 +3.5 5 4.6925178097141469 -15.892083876813002 +4 0.0 27.28991719712775 0.0 +4 0.5 23.949155447631512 13.092264235736186 +4 1 14.744805188558725 22.979085577886128 +4 1.5 1.9304123762681393 27.239825346942666 +4 2 -11.356612711218173 24.831305848946378 +4 2.5 -21.863142931283367 16.343216657060854 +4 3 -27.016813258003932 3.8537380379193769 +4 3.5 -25.555825454862386 -9.5792700567175242 +4 4 -17.837880289798733 -20.666938752747178 +4 4.5 -5.7525999119683275 -26.694620057417062 +4 5 7.741117553247741 -26.186527364609208 +4.5 0.0 45.003011151991785 0.0 +4.5 0.5 39.493857819545966 21.580918797003314 +4.5 1 24.315230696430771 37.878076011644538 +4.5 1.5 3.1833870755123259 44.901359174551253 +4.5 2 -18.727860725997154 40.931223621880427 +4.5 2.5 -36.053875064805673 26.939697000243871 +4.5 3 -44.552643364898032 6.352392998168388 +4.5 3.5 -42.143370741504995 -15.790198357309713 +4.5 4 -29.41593115915342 -34.066798452498411 +4.5 4.5 -9.486445712576403 -44.002658165383373 +4.5 5 12.765652495799936 -43.165132513028524 +5 0.0 74.203210577788752 0.0 +5 0.5 65.119443639346656 35.578144541286591 +5 1 40.092165777998403 62.445518467696537 +5 1.5 5.2489274710320686 74.024051609620827 +5 2 -30.879431343588244 67.478915238455883 +5 2.5 -59.447428407480153 44.412587007474023 +5 3 -73.460621695673666 10.472508533940392 +5 3.5 -69.488092764017438 -26.031605270205624 +5 4 -48.50245524177091 -56.162274220232348 +5 4.5 -15.64172509407547 -72.542459713356664 +5 5 21.04864488088355 -71.161721061921028 diff --git a/commons-numbers-complex/src/test/resources/data/sqrt.txt b/commons-numbers-complex/src/test/resources/data/sqrt.txt new file mode 100644 index 0000000..1c964df --- /dev/null +++ b/commons-numbers-complex/src/test/resources/data/sqrt.txt @@ -0,0 +1,243 @@ +# (a + b i) sqrt(a + b i) +0.0 0.0 0.0 0.0 +0.0 0.5 0.5 0.5 +0.0 1 0.70710678118654757 0.70710678118654746 +0.0 1.5 0.8660254037844386 0.86602540378443871 +0.0 2 1 1 +0.0 2.5 1.1180339887498949 1.1180339887498949 +0.0 3 1.2247448713915889 1.2247448713915892 +0.0 3.5 1.3228756555322954 1.3228756555322951 +0.0 4 1.4142135623730951 1.4142135623730949 +0.0 4.5 1.5 1.5 +0.0 5 1.5811388300841898 1.5811388300841895 +0.5 0.0 0.70710678118654757 0.0 +0.5 0.5 0.77688698701501868 0.32179712645279129 +0.5 1 0.89945371997393364 0.55589297025142115 +0.5 1.5 1.0200830432087846 0.73523425861564329 +0.5 2 1.1317139242778693 0.88361553087551337 +0.5 2.5 1.2348096526988264 1.0123017723970438 +0.5 3 1.3306729998668174 1.1272491439670977 +0.5 3.5 1.4204812399206013 1.2319768475772459 +0.5 4 1.5051792043057988 1.3287454372733092 +0.5 4.5 1.5855113637354841 1.4191005195314228 +0.5 5 1.6620676596577597 1.5041505593790212 +1 0.0 1 0.0 +1 0.5 1.0290855136357462 0.24293413587832283 +1 1 1.09868411346781 0.45508986056222733 +1 1.5 1.1838022718621541 0.63355174916181656 +1 2 1.272019649514069 0.78615137775742328 +1 2.5 1.3587829855365521 0.91994086863429758 +1 3 1.442615274452683 1.0397782600555705 +1 3.5 1.5231636393769807 1.1489244850381291 +1 4 1.6004851804402409 1.2496210676876531 +1 4.5 1.6747794225877095 1.3434604997256978 +1 5 1.7462845577958914 1.4316108957382214 +1.5 0.0 1.2247448713915889 0.0 +1.5 0.5 1.2411967672541269 0.20141850719855617 +1.5 1 1.2850633520826891 0.38908587595285093 +1.5 1.5 1.345607733249115 0.55736897274590136 +1.5 2 1.4142135623730951 0.70710678118654746 +1.5 2.5 1.4858458781822983 0.84127164085765138 +1.5 3 1.5578995420516826 0.96283486804583596 +1.5 3.5 1.6290927771204369 1.0742175182270939 +1.5 4 1.6988233976283063 1.1772854098855481 +1.5 4.5 1.766835658777093 1.27346309138753 +1.5 5 1.8330511796531044 1.3638462623139154 +2 0.0 1.4142135623730951 0.0 +2 0.5 1.425053124063947 0.17543205637629383 +2 1 1.4553466902253549 0.34356074972251244 +2 1.5 1.5 0.5 +2 2 1.5537739740300374 0.64359425290558259 +2 2.5 1.6126937276985398 0.77510067691765838 +2 3 1.6741492280355401 0.89597747612983814 +2 3.5 1.7365380609346395 1.0077521704638683 +2 4 1.7989074399478673 1.1117859405028423 +2 4.5 1.8607026765308385 1.2092205962722542 +2 5 1.9216093264675971 1.3009928530039094 +2.5 0.0 1.5811388300841898 0.0 +2.5 0.5 1.5889477267670564 0.15733683102883511 +2.5 1 1.6113010897357534 0.31030823673184377 +2.5 1.5 1.6455205783311631 0.45578281419040484 +2.5 2 1.6884256155834085 0.5922677260818896 +2.5 2.5 1.7371721138005782 0.71956024971253707 +2.5 3 1.7895704565556125 0.83818996592458894 +2.5 3.5 1.8440665163601493 0.94898962942734877 +2.5 4 1.899603980574412 1.0528510260308201 +2.5 4.5 1.9554814075431017 1.1506118091027704 +2.5 5 2.0112396604767762 1.243014469696446 +3 0.0 1.7320508075688772 0.0 +3 0.5 1.7380134155335381 0.14384238796180673 +3 1 1.7553173018244279 0.28484878459314106 +3 1.5 1.7824283949502271 0.42077426623409642 +3 2 1.8173540210239707 0.55025052270033747 +3 2.5 1.8581072140693775 0.67272759641378144 +3 3 1.9029767059950162 0.78823876050321362 +3 3.5 1.9506117282337923 0.89715445399508653 +3 4 2 1 +3 4.5 2.0504056809807159 1.0973438187723989 +3 5 2.1013033925215678 1.189737764140758 +3.5 0.0 1.8708286933869707 0.0 +3.5 0.5 1.8755711004828286 0.13329273410943604 +3.5 1 1.889451632701967 0.26462704381852126 +3.5 1.5 1.9115290414916477 0.3923560582761238 +3.5 2 1.9405062321658844 0.51532944518495882 +3.5 2.5 1.9749889409211021 0.63291493643352792 +3.5 3 2.0136747786877658 0.74490678230448526 +3.5 3.5 2.0554497644440053 0.85139516920929037 +3.5 4 2.0994133592943678 0.95264707693020423 +3.5 4.5 2.1448632969837136 1.049017903921494 +3.5 5 2.1912642250384651 1.1408939056430383 +4 0.0 2 0.0 +4 0.5 2.0038873314322432 0.12475751309896096 +4 1 2.0153294551533829 0.24809839340235612 +4 1.5 2.0337160412234012 0.36878304777929094 +4 2 2.0581710272714924 0.48586827175664565 +4 2.5 2.0877009563187325 0.59874475614751821 +4 3 2.1213203435596424 0.70710678118654757 +4 3.5 2.1581326310455671 0.81088621469578726 +4 4 2.1973682269356201 0.91017972112445467 +4 4.5 2.2383919774467729 1.0051858756956715 +4 5 2.2806933416652981 1.0961578895015189 +4.5 0.0 2.1213203435596424 0.0 +4.5 0.5 2.1245814374917131 0.11767023639966973 +4.5 1 2.1342179163157686 0.23427785709115115 +4.5 1.5 2.14981586307439 0.34886708805257699 +4.5 2 2.1707635639214664 0.46066739677236351 +4.5 2.5 2.1963395764878322 0.56912875102805172 +4.5 3 2.2257950167519902 0.6739165056577795 +4.5 3.5 2.2584150554643063 0.77487970856633281 +4.5 4 2.293555895263526 0.87200839714883127 +4.5 4.5 2.3306609610450559 0.96539137935837394 +4.5 5 2.3692627570129123 1.0551805588468866 +5 0.0 2.2360679774997898 0.0 +5 0.5 2.2388543733973014 0.11166425247241199 +5 1 2.2471114250958699 0.22250788030178262 +5 1.5 2.260547859972807 0.33177797881661397 +5 2 2.2787238541708499 0.4388421169022545 +5 2.5 2.3011051631498152 0.54321724187910048 +5 3 2.3271175190399496 0.64457423732464691 +5 3.5 2.3561916101907809 0.74272397560158632 +5 4 2.3877944046161983 0.83759305078088142 +5 4.5 2.4214470904334102 0.92919643335972157 +5 5 2.4567323635131153 1.0176118640880409 +-0.0 -0.0 0.0 -0.0 +-0.0 -0.5 0.5 -0.5 +-0.0 -1 0.70710678118654746 -0.70710678118654757 +-0.0 -1.5 0.86602540378443871 -0.8660254037844386 +-0.0 -2 1 -1 +-0.0 -2.5 1.1180339887498949 -1.1180339887498949 +-0.0 -3 1.2247448713915892 -1.2247448713915889 +-0.0 -3.5 1.3228756555322951 -1.3228756555322954 +-0.0 -4 1.4142135623730949 -1.4142135623730951 +-0.0 -4.5 1.5 -1.5 +-0.0 -5 1.5811388300841895 -1.5811388300841898 +-0.5 -0.0 0.0 -0.70710678118654757 +-0.5 -0.5 0.32179712645279129 -0.77688698701501868 +-0.5 -1 0.55589297025142115 -0.89945371997393364 +-0.5 -1.5 0.73523425861564329 -1.0200830432087846 +-0.5 -2 0.88361553087551337 -1.1317139242778693 +-0.5 -2.5 1.0123017723970438 -1.2348096526988264 +-0.5 -3 1.1272491439670977 -1.3306729998668174 +-0.5 -3.5 1.2319768475772459 -1.4204812399206013 +-0.5 -4 1.3287454372733092 -1.5051792043057988 +-0.5 -4.5 1.4191005195314228 -1.5855113637354841 +-0.5 -5 1.5041505593790212 -1.6620676596577597 +-1 -0.0 0.0 -1 +-1 -0.5 0.24293413587832283 -1.0290855136357462 +-1 -1 0.45508986056222733 -1.09868411346781 +-1 -1.5 0.63355174916181656 -1.1838022718621541 +-1 -2 0.78615137775742328 -1.272019649514069 +-1 -2.5 0.91994086863429758 -1.3587829855365521 +-1 -3 1.0397782600555705 -1.442615274452683 +-1 -3.5 1.1489244850381291 -1.5231636393769807 +-1 -4 1.2496210676876531 -1.6004851804402409 +-1 -4.5 1.3434604997256978 -1.6747794225877095 +-1 -5 1.4316108957382214 -1.7462845577958914 +-1.5 -0.0 0.0 -1.2247448713915889 +-1.5 -0.5 0.20141850719855617 -1.2411967672541269 +-1.5 -1 0.38908587595285093 -1.2850633520826891 +-1.5 -1.5 0.55736897274590136 -1.345607733249115 +-1.5 -2 0.70710678118654746 -1.4142135623730951 +-1.5 -2.5 0.84127164085765138 -1.4858458781822983 +-1.5 -3 0.96283486804583596 -1.5578995420516826 +-1.5 -3.5 1.0742175182270939 -1.6290927771204369 +-1.5 -4 1.1772854098855481 -1.6988233976283063 +-1.5 -4.5 1.27346309138753 -1.766835658777093 +-1.5 -5 1.3638462623139154 -1.8330511796531044 +-2 -0.0 0.0 -1.4142135623730951 +-2 -0.5 0.17543205637629383 -1.425053124063947 +-2 -1 0.34356074972251244 -1.4553466902253549 +-2 -1.5 0.5 -1.5 +-2 -2 0.64359425290558259 -1.5537739740300374 +-2 -2.5 0.77510067691765838 -1.6126937276985398 +-2 -3 0.89597747612983814 -1.6741492280355401 +-2 -3.5 1.0077521704638683 -1.7365380609346395 +-2 -4 1.1117859405028423 -1.7989074399478673 +-2 -4.5 1.2092205962722542 -1.8607026765308385 +-2 -5 1.3009928530039094 -1.9216093264675971 +-2.5 -0.0 0.0 -1.5811388300841898 +-2.5 -0.5 0.15733683102883511 -1.5889477267670564 +-2.5 -1 0.31030823673184377 -1.6113010897357534 +-2.5 -1.5 0.45578281419040484 -1.6455205783311631 +-2.5 -2 0.5922677260818896 -1.6884256155834085 +-2.5 -2.5 0.71956024971253707 -1.7371721138005782 +-2.5 -3 0.83818996592458894 -1.7895704565556125 +-2.5 -3.5 0.94898962942734877 -1.8440665163601493 +-2.5 -4 1.0528510260308201 -1.899603980574412 +-2.5 -4.5 1.1506118091027704 -1.9554814075431017 +-2.5 -5 1.243014469696446 -2.0112396604767762 +-3 -0.0 0.0 -1.7320508075688772 +-3 -0.5 0.14384238796180673 -1.7380134155335381 +-3 -1 0.28484878459314106 -1.7553173018244279 +-3 -1.5 0.42077426623409642 -1.7824283949502271 +-3 -2 0.55025052270033747 -1.8173540210239707 +-3 -2.5 0.67272759641378144 -1.8581072140693775 +-3 -3 0.78823876050321362 -1.9029767059950162 +-3 -3.5 0.89715445399508653 -1.9506117282337923 +-3 -4 1 -2 +-3 -4.5 1.0973438187723989 -2.0504056809807159 +-3 -5 1.189737764140758 -2.1013033925215678 +-3.5 -0.0 0.0 -1.8708286933869707 +-3.5 -0.5 0.13329273410943604 -1.8755711004828286 +-3.5 -1 0.26462704381852126 -1.889451632701967 +-3.5 -1.5 0.3923560582761238 -1.9115290414916477 +-3.5 -2 0.51532944518495882 -1.9405062321658844 +-3.5 -2.5 0.63291493643352792 -1.9749889409211021 +-3.5 -3 0.74490678230448526 -2.0136747786877658 +-3.5 -3.5 0.85139516920929037 -2.0554497644440053 +-3.5 -4 0.95264707693020423 -2.0994133592943678 +-3.5 -4.5 1.049017903921494 -2.1448632969837136 +-3.5 -5 1.1408939056430383 -2.1912642250384651 +-4 -0.0 0.0 -2 +-4 -0.5 0.12475751309896096 -2.0038873314322432 +-4 -1 0.24809839340235612 -2.0153294551533829 +-4 -1.5 0.36878304777929094 -2.0337160412234012 +-4 -2 0.48586827175664565 -2.0581710272714924 +-4 -2.5 0.59874475614751821 -2.0877009563187325 +-4 -3 0.70710678118654757 -2.1213203435596424 +-4 -3.5 0.81088621469578726 -2.1581326310455671 +-4 -4 0.91017972112445467 -2.1973682269356201 +-4 -4.5 1.0051858756956715 -2.2383919774467729 +-4 -5 1.0961578895015189 -2.2806933416652981 +-4.5 -0.0 0.0 -2.1213203435596424 +-4.5 -0.5 0.11767023639966973 -2.1245814374917131 +-4.5 -1 0.23427785709115115 -2.1342179163157686 +-4.5 -1.5 0.34886708805257699 -2.14981586307439 +-4.5 -2 0.46066739677236351 -2.1707635639214664 +-4.5 -2.5 0.56912875102805172 -2.1963395764878322 +-4.5 -3 0.6739165056577795 -2.2257950167519902 +-4.5 -3.5 0.77487970856633281 -2.2584150554643063 +-4.5 -4 0.87200839714883127 -2.293555895263526 +-4.5 -4.5 0.96539137935837394 -2.3306609610450559 +-4.5 -5 1.0551805588468866 -2.3692627570129123 +-5 -0.0 0.0 -2.2360679774997898 +-5 -0.5 0.11166425247241199 -2.2388543733973014 +-5 -1 0.22250788030178262 -2.2471114250958699 +-5 -1.5 0.33177797881661397 -2.260547859972807 +-5 -2 0.4388421169022545 -2.2787238541708499 +-5 -2.5 0.54321724187910048 -2.3011051631498152 +-5 -3 0.64457423732464691 -2.3271175190399496 +-5 -3.5 0.74272397560158632 -2.3561916101907809 +-5 -4 0.83759305078088142 -2.3877944046161983 +-5 -4.5 0.92919643335972157 -2.4214470904334102 +-5 -5 1.0176118640880409 -2.4567323635131153 diff --git a/commons-numbers-complex/src/test/resources/data/tanh.txt b/commons-numbers-complex/src/test/resources/data/tanh.txt new file mode 100644 index 0000000..30f2260 --- /dev/null +++ b/commons-numbers-complex/src/test/resources/data/tanh.txt @@ -0,0 +1,122 @@ +# (a + b i) tanh(a + b i) +0.0 0.0 0.0 0.0 +0.0 0.5 0.0 0.54630248984379048 +0.0 1 0.0 1.5574077246549021 +0.0 1.5 0.0 14.101419947171721 +0.0 2 0.0 -2.1850398632615189 +0.0 2.5 0.0 -0.7470222972386602 +0.0 3 0.0 -0.1425465430742778 +0.0 3.5 0.0 0.37458564015859463 +0.0 4 0.0 1.1578212823495775 +0.0 4.5 0.0 4.6373320545511838 +0.0 5 0.0 -3.380515006246585 +0.5 0.0 0.46211715726000974 0.0 +0.5 0.5 0.56408314126749848 0.40389645531602569 +0.5 1 1.042830728344361 0.80687741216308495 +0.5 1.5 2.1247991277429965 0.25514922181365163 +0.5 2 1.3212865837711916 -0.85087812114493766 +0.5 2.5 0.64333149724089389 -0.52493665994918715 +0.5 3 0.46946999342588541 -0.11162105077158345 +0.5 3.5 0.51162818808559429 0.28602154670793489 +0.5 4 0.84088258866597276 0.70790782721996881 +0.5 4.5 1.8596415857688275 0.65213741916255907 +0.5 5 1.6692982861500605 -0.77274726485031864 +1 0.0 0.76159415595576485 0.0 +1 0.5 0.84296620484578311 0.19557731006593398 +1 1 1.0839233273386943 0.27175258531951174 +1 1.5 1.3082952992279355 0.050905362327228622 +1 2 1.1667362572409197 -0.24345820118572525 +1 2.5 0.89643791712786169 -0.23701383091627057 +1 3 0.76801764728691124 -0.05916853956605074 +1 3.5 0.80309604700217541 0.14547660539206481 +1 4 1.002810507583505 0.27355308280730739 +1 4.5 1.2721070413547244 0.14454893985282793 +1 5 1.2407479829240695 -0.18610947764730421 +1.5 0.0 0.90514825364486651 0.0 +1.5 0.5 0.94437298642262146 0.079324454803956682 +1.5 1 1.0379587828579326 0.094212920129544422 +1.5 1.5 1.1035734368075187 0.01554584115148238 +1.5 2 1.0641443991765371 -0.080391015310168179 +1.5 2.5 0.96778680215277413 -0.092637836268419885 +1.5 3 0.90841741793375763 -0.02533730030009158 +1.5 3.5 0.9257326109113867 0.060710871694121191 +1.5 4 1.0096463820896704 0.099711963019300881 +1.5 4.5 1.0940687171244692 0.045008142517137986 +1.5 5 1.085526003516625 -0.058949534368472854 +2 0.0 0.96402758007581679 0.0 +2 0.5 0.97994084996173791 0.030215987322877568 +2 1 1.0147936161466333 0.033812826079896691 +2 1.5 1.0369202821001851 0.0053620609220030556 +2 2 1.0238355945704725 -0.028392952868232284 +2 2.5 0.98905556055077481 -0.034753838905107304 +2 3 0.96538587902213313 -0.0098843750383224935 +2 3.5 0.97248185532763265 0.023411853609972968 +2 4 1.0046823121902351 0.036423369247403692 +2 4.5 1.0338224477663269 0.01561226214446799 +2 5 1.031008005152491 -0.020553016568255644 +2.5 0.0 0.9866142981514302 0.0 +2.5 0.5 0.99268176030463717 0.011257099146251948 +2.5 1 1.0055480118950599 0.012322138255828353 +2.5 1.5 1.0134287782038933 0.0019273435237456356 +2.5 2 1.0087947005319187 -0.010288750859582028 +2.5 2.5 0.99610167731576527 -0.012872570755000074 +2.5 3 0.9871370665772804 -0.0037171086412651618 +2.5 3.5 0.98985324001586439 0.0087640454951346293 +2.5 4 1.0018735316286926 0.013358072149067335 +2.5 4.5 1.0123384296816598 0.0056224437857046797 +2.5 5 1.0113441956285463 -0.0074146736847805223 +3 0.0 0.99505475368673058 0.0 +3 0.5 0.99731636528320211 0.0041604265928938304 +3 1 1.0020549882458119 0.0045171372766584245 +3 1.5 1.0049197189087831 0.00070304922435774687 +3 2 1.0032386273536098 -0.003764025641504248 +3 2.5 0.99858345578407059 -0.0047471663649117967 +3 3 0.99525030117860314 -0.0013786327196592897 +3 3.5 0.99626422318841701 0.0032448663832883632 +3 4 1.0007095360672331 0.0049082580674960604 +3 4.5 1.0045250553806742 0.0020523368411260227 +3 5 1.0041647106948155 -0.0027082358362240724 +3.5 0.0 0.99817789761119879 0.0 +3.5 0.5 0.99901392556700208 0.0015331324323737694 +3.5 1 1.0007578650873443 0.0016596020306081799 +3.5 1.5 1.0018071108086137 0.00025783489040553232 +3.5 2 1.0011918484035776 -0.0013818752668270382 +3.5 2.5 0.99948127286602395 -0.0017479457815338076 +3.5 3 0.99825027844029568 -0.00050869669345581534 +3.5 3.5 0.99862528849210275 0.0011965422934573184 +3.5 4 1.0002637644287953 0.0018048333108071162 +3.5 4.5 1.0016627850956348 0.00075285721538218692 +3.5 5 1.0015309468194109 -0.00099368585958443012 +4 0.0 0.99932929973906703 0.0 +4 0.5 0.99963740394963996 0.00056435949051924475 +4 1 1.0002790562344657 0.00061024092137625997 +4 1.5 1.0006644271437029 9.4743896780242226e-05 +4 2 1.0004385132020521 -0.00050798062347003872 +4 2.5 0.99980949508290229 -0.0006432440221791259 +4 3 0.99935598738147335 -0.0001873462046294785 +4 3.5 0.99949421875397682 0.00044056600862506023 +4 4 1.0000974040746433 0.00066385016481112515 +4 4.5 1.0006114489437932 0.00027666979732894273 +4 5 1.0005630461157935 -0.0003652030545113042 +4.5 0.0 0.9997532108480276 0.0 +4.5 0.5 0.99986663012447585 0.00020766384212757996 +4.5 1 1.0001026932855714 0.00022445548572470905 +4.5 1.5 1.0002443788102788 3.4839697628939659e-05 +4.5 2 1.0001613276272889 -0.0001868238331855109 +4.5 2.5 0.99992996105530152 -0.00023666474043523337 +4.5 3 0.9997630368473448 -6.8948882616261698e-05 +4.5 3.5 0.99981392630805066 0.00016212700415590609 +4.5 4 1.0000358830894707 0.00024420178089365013 +4.5 4.5 1.0002249049285517 0.00010174180168501476 +4.5 5 1.0002071117356188 -0.00013430288941751654 +5 0.0 0.99990920426259533 0.0 +5 0.5 0.99995093891122622 7.6401698837941958e-05 +5 1 1.0000377833796006 8.2567198342295967e-05 +5 1.5 1.0000898951379096 1.281482882166464e-05 +5 2 1.0000593501490003 -6.8721638801192764e-05 +5 2.5 0.9999742400546392 -8.7067946690634452e-05 +5 3 0.99991282015135385 -2.536867620767604e-05 +5 3.5 0.9999315463449856 5.9650207442154342e-05 +5 4 1.0000132074347847 8.9834776469715626e-05 +5 4.5 1.0000827332218711 3.7423396546759517e-05 +5 5 1.0000761892591823 -4.940080407311289e-05 diff --git a/pom.xml b/pom.xml index 3bff646..a1fb00f 100644 --- a/pom.xml +++ b/pom.xml @@ -317,8 +317,7 @@ <!-- version 0.8 of apache-rat-plugin does not exclude properly some default development tools files (see RAT-126) --> <exclude>.ekstazi/**</exclude> - <exclude>src/site/resources/txt/userguide/stress/dh/**</exclude> - <exclude>src/site/resources/txt/userguide/stress/tu/**</exclude> + <exclude>src/test/resources/data/**</exclude> <exclude>dist-archive/**</exclude> </excludes> </configuration>