*/
public void testCbrt() {
Complex[] x;
// Trivial case, square root of a positive real number
x = ComplexMath.cbrt(new Complex(8, 0));
assertTrue(x.length == 3);
for (int i = 0; i < x.length; i++) {
assertTrue(approximatelyEqual(x[i], new Complex(-1, -1.7320508075688773))
|| approximatelyEqual(x[i], new Complex(-1, 1.7320508075688773))
|| approximatelyEqual(x[i], new Complex(2, 0)));
}
// Square root of a negative real number
x = ComplexMath.cbrt(new Complex(-9, 0));
assertTrue(x.length == 3);
for (int i = 0; i < x.length; i++) {
assertTrue(approximatelyEqual(x[i], new Complex(-2.0800838230519041, 0))
|| approximatelyEqual(x[i], new Complex(1.0400419115259521,
-1.8014054327640041))
|| approximatelyEqual(x[i], new Complex(1.0400419115259521,
1.8014054327640041)));
}
// Square root of complex number
x = ComplexMath.cbrt(new Complex(8, -23));
assertTrue(x.length == 3);
for (int i = 0; i < x.length; i++) {
assertTrue(approximatelyEqual(x[i], new Complex(-2.3332080247967582,
-1.7197495217100161))
|| approximatelyEqual(x[i], new Complex(-0.3227427615486328,
2.8804921826427131))
|| approximatelyEqual(x[i], new Complex(2.6559507863453910,
-1.1607426609326970)));
}
}